Question
How do you clean your /tmp directory with tmpwatch?
Answer
-
Install tmpwatch (if it's not already installed) by running the following command:
# yum install tmpwatch
-
Check how many files are in
/tmp:# ls -1 /tmp | wc -l
-
Run tmpwatch to clear the
/tmppartition of files over a week old now. This command ignores symlinks and preserves certain systemd data stored in/tmp:# tmpwatch --verbose --mtime -l -X "/tmp/systemd-private*" 168 /tmp
-
Check to see if some files were actually removed from
/tmp. If not, decrease the number of hours (in this case 168) until enough files are removed to give sufficient space in/tmp.Warning: Do not lower the number below 12.
# ls -1 /tmp | wc -l
-
Open the root crontab:
# crontab -e
-
Add tmpwatch to root's crontab to clear old files (more than a week old) every night. If you lowered the number of hours in step 3, lower it here as well.
CONFIG_TEXT: 0 0 * * * tmpwatch --mtime -l -X "/tmp/systemd-private*" 168 /tmp
Comments
0 comments
Article is closed for comments.