1

On a server that's up 24/7/365: where and how are the cleanup of /tmp (and /var/tmp) defined / controlled / configured?

slashmais
  • 263
  • 1
  • 9

2 Answers2

4

I agree with Torian's suggestion of using tmpwatch. One thing to watch (har har) out for is that tmpwatch uses file atime by default to decide if a file should be deleted. If you are mounting your /tmp partition with noatime this can lead to problems. Use relatime instead, particularly since newer kernels have a much smarter handling of this flag.

Kamil Kisiel
  • 12,184
  • 7
  • 48
  • 69
3

In general that is entirely up to the distribution you are using, but you can assume that if something is being deleted it is done from a cronjob, and surely runs from /etc/cron.daily (could also be cron.weekly or /etc/cron.d).

If tmpwatch is installed then that is what is erasing your files and directories. In its most simple way it is executed as tmpwatch <hours> <dir1> [<dir2>, ...]

Another variant is tmpreaper.

wolfgangsz
  • 8,847
  • 3
  • 30
  • 34
Torian
  • 2,364
  • 18
  • 10