Install tmpwatch CentOS Print

  • 5

By default TMPwatch is already installed.
If not please run:

yum install tmpwatch -y

To clean up files not accessed by 2 weeks (24 * 14 days = 336) :

tmpwatch --mtime --all 336 /tmp

If you want to delete old files even if they accessed (12 hours old):

/usr/sbin/tmpwatch -am 12 /tmp

If you not want to remove but just test what will be removed:

tmpwatch --mtime -t --all 336 /tmp

Also it is possible to automate the task, we go run:

crontab -e

And paste the following code:

0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp

then press Control+X (on PC) or Command+x (on Mac)
you will get confirmation do you want to save. Type Y for yes, and press enter


Was dit antwoord nuttig?

« Terug