What mechanism controls how often/when the /tmp directory is cleaned up. If there is such built-in mechanism at all or do I need to resort to a custom cron?

I'd appreciate either a specific command/tool or if you just point me to where I can find the appropriate documentation.

I am using Ubuntu 10.04 server if it matters.

link|improve this question
There is no built-in mechanism. Have a look at this serverfault.com/questions/143852/… – Iain Sep 1 '10 at 19:29
feedback

4 Answers

up vote 2 down vote accepted

On Ubuntu, install tmpreaper.

apt-get install tmpreaper
link|improve this answer
Thank you. tmpreaper tool is exactly what I was looking for – Sergey G Sep 1 '10 at 19:53
feedback

tmpwatch can be used to clean up /tmp.

link|improve this answer
feedback

Well, you can mount it in in swap/ramdisk (google for how to set that up) Solaris does this by default, cleans up with every reboot. :-) I've done it with Linux, it can be very nice, and makes /tmp nice and fast.

Personally, I would only delete stuff from /tmp that is older than the last reboot, or that I know is safe, lots of things have working data in /tmp, and it may we be from just after boot (I don't know that for sure, but I would be cautious, granted, worst case, reboot and you are fixed).

link|improve this answer
feedback

For long uptimes, tmpreaper is the way to go.

Ubuntu cleans /tmp at each boot. If you reboot, files may be deleted that you may have intended to keep based on thresholds supplied to tmpreaper. You can control boot-time /tmp cleaning using the TMPTIME variable.

From man rcS:

TMPTIME
On boot the files in /tmp will be deleted if their modification time is more than TMPTIME days ago. A value of 0 means that files are removed regardless of age. If you don't want the system to clean /tmp then set TMPTIME to a negative value (e.g., -1) or to the word infinite.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.