Tech- Brew

The best page to pretend you're working
A Blog written by Zanidd
Card image cap

How to change the /tmp cleanup frequency in linux

September 27, 2016 by Zanidd

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 0.

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 (TMPTIME=-1).

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.