Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know it clears out /tmp on reboots, but I haven't been able to find any sort of cron job on my server that clears /tmp. I recently set up a script that writes lots of files to /tmp and my server usually goes several months between reboots so I'm concerned about it being cluttered.

I've seen several other distros that have a tmpwatch script installed by default. Ubuntu's repository seems to have replaced tmpwatch with tmpreaper.

Is there any mechanism in place on Ubuntu (8.04 currently, soon to be upgraded to 10.04 when I get around to it) to clean up temp files on a server that doesn't regularly reboot or do I need to install tmpreaper?

share|improve this question
5  
Shouldn't your update/fix/file-a-bug for the script so that it cleans up its temp files when it is done with them? It is very poor design for a program to write temp files and not have a facility to clean up after itself. – Zoredache May 20 '10 at 18:49
    
What Zoredache said -- Scripts (& users) should clean up after themselves. tmpwatch/tmpreaper/whatever is a brute force fix for ill-behaved code (that being said, I run a tmp-cleaner myself - I have a bad habit of leaving junk in /tmp :) – voretaq7 May 20 '10 at 19:01
up vote 5 down vote accepted

You will need to install tmpreaper.

share|improve this answer
7  
...or fix the script to clean up its own mess :-) – voretaq7 May 20 '10 at 19:05
    
@voretaq7 Why should a script clean up its mess? If the user waits for the result of the script, it is better for the script to be fast. Why should the user wait for stuff that can be done later? – guettli Jan 6 at 13:35
2  
@guettli Lots of reasons: Because it's good practice. Because /tmp isn't a magical infinite pool and 1000 scripts all leaving their detritus in it can fill the volume (which breaks things). Because it doesn't take appreciable time to clean up your temporary files (do it right before you exit, no different than clearing a lock that prevents 2 copies of a script from being run). Because guessing that a temp file is OK to delete just because it's X days old is a kludge that can in fact break things. I can go on if you'd like… – voretaq7 Jan 20 at 22:32
    
"Because it's good practice." is no argument for me. "Because /tmp isn't a magical infinite pool" that's correct. "Because it doesn't take appreciable time to clean up your temporary files" that's correct. "Because guessing that a temp file is OK to delete just because it's X days old is a kludge that can in fact break things." I don't get this one. Do you do backup up tmp? I don't. If a server was burned and the backup gets restored, then nothing serious should break. – guettli Jan 21 at 14:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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