Changing The /tmp Cleanup Frequency
->
While the /tmp folder is not a place to store files long-term, occasionally you want to keep things a little longer than the next time you reboot, which is the default on Ubuntu systems. I know a time or two I’ve downloaded something to /tmp during testing, rebooted after making changes and then lost the original data again. This can be changed if you’d like to keep your /tmp files a little bit longer. The default on Redhat systems, for example, is to keep files roughly ten-days.
Changing the /tmp Cleanup Frequency
The default setting that tells your system to clear /tmp at reboot is held in the /etc/default/rcS file. The value we’ll look at is TMPTIME.
The current value of TMPTIME=0 says delete files at reboot despite the age of the file. Changing this value to a different (positive) number will change the number of days a file can survive in /tmp.
TMPTIME=7
This setting would allow files to stay in /tmp until they are a week old, and then delete them on the next reboot. A negative number (TMPTIME=-1) tells the system to never delete anything in /tmp. This is probably not something you want, but is available.
I have been wondering how to do this on Ubuntu and finally found it today. Enjoy.
That’s great Christer, very handy to know!
Interesting, but I think it’s the wrong approach. Technically, you’re not guaranteed that anything in /tmp will be there even 5 minutes from now, reboot or not. It just so happens that most linux distros only clean up /tmp on reboot, but other unices aren’t so predictable. /tmp is just a bad place to put things that you don’t want to lose yet, just like the trash is a bad place to put leftovers you may or may not want to eat tomorrow. I make a ~/tmp for that purpose. I should probably find another name for it, but I haven’t had any bursts of creativity on the subject yet.
only every reboot?
Isn’t there a cron of some sort which cleans the /tmp dir too?
I’ve got my pc turned 24/7 or in suspend does that mean my tmp dir doesn’t get cleaned?
Some people have /tmp on a tmpfs, which is in RAM and thus reset at reboot…
I don’t reboot my laptop often, but when I do, /tmp might have become quite big. Not cleaning out /tmp on boot every time might actually improve boot-up times. I’ll see how it goes
@Tormod: you are right, and in fact Ubuntu’s default configuration is to put /tmp in a RAM based file system (tmpfs). So *anything* you put in /tmp will be automatically lost on reboot.
To check this on your system, just type ‘mount’ or ‘df -hT’ (h for human units, T for show types).
@Richard Ubuntu (default Feisty and Intrepid) has NOT a default /tmp as tmpfs so setting TMPTIME in /etc/default/rcS works.
I know this is an old thread, and my question is not directly related, but some of you seem like experts on the tmp directory. There seems to be a bug in ubuntu with the tmp directory filling up and then certain programs, like Firefox, doing things like not letting you download anything or watch video.
Here's a couple bug reports on it:
https://bugs.launchpad.net/ubuntu/+source/sysvini...
https://bugs.launchpad.net/ubuntu/+bug/285096
I'm running Jaunty 9.04 64 bit, I've got a big harddrive (250g)+ with tons of free space, 4g RAM.
I feel like this should be an easy fix, like setting some config setting to allow a bigger tmp directory. Thanks for any help.
It seems that Unbutu 9.10 (/sbin/mountall) counts TMPTIME in hours instead of days.