Skip to content

How to change the /tmp cleanup frequency in linux

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

Add:

0 3 * * 1 rm -rf /tmp/*

This would clear the tmp every weekend at 3 AM.

Published inLinuxQuickies

Be First to Comment

Leave a Reply

%d bloggers like this: