3

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?

DWilliams
  • 953
  • 2
  • 20
  • 28
  • 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

1 Answers1

5

You will need to install tmpreaper.

Adam
  • 581
  • 3
  • 8
  • 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 06 '16 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 '16 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 '16 at 14:11