0

I am implementing my own file cache server using Play framework, and I put my cached files in /tmp directory.

However I do not know how the OS manages the /tmp directory. What I wish to know is if the OS will automatically cleanup some files that are old enough, or have not been accessed for a long time.

I am running my server in a Docker container, based on Debian jessie.

Khanetor
  • 11,595
  • 8
  • 40
  • 76
  • Not that it matters for your question, but is `/tmp` mounted from the host OS or inside the Docker container? – Thilo Oct 06 '15 at 11:34
  • I am having it mounted inside the Docker container. I think it would be interesting to mount the volume with the host OS, and have another container do the cleanup. – Khanetor Oct 06 '15 at 11:35

1 Answers1

1

Your OS won't clean up /tmp. Some Unix variants clear it out at reboot. You will need to do this yourself.

 find /tmp/yourpath -mtime +30 -type f -exec rm {} \;

For example.

But Docker is a bit of a special case, as the containers are an encapsulation layer. That find will still do the trick, but you could probably just dump and restart your container 'fresh' and trash the old one.

Sobrique
  • 52,974
  • 7
  • 60
  • 101