Every time you boot up your machine, the
tmp directory is cleared. But this is just the default. Read how to change the frequency:
Open the file
/etc/default/rcS and search for the value
TMPTIME. It should be set to
The value represents how frequently in days the
tmp directory should be cleared. For example
TMPTIME=21 will delete all the files in the tmp directory after 21 days have passed.
To shut off the cleaning set the value to a negative number (
If you’re running a server that rarely reboots, you can use crontab to clean the tmp directory:
$ crontab -e
0 3 * * 1 rm -rf /tmp/*
This would clear the tmp every weekend at 3 AM.