How can I clean /tmp while system is running?
I know I can put a command in the shutdown script to clean /tmp, but I rarely reboot my computer. So how should I manage this? Do I use cron and periodically delete files that are certain age? Could someone provide examples? Thank you.
|
Hi there,
Yes, a daily cron job should do the trick nicely. Possibly something like this: Code:
find /tmp -xdev -type f -atime +1 -print | xargs rm |
Back when I ran Slackware (14'ish), I installed tmpwatch.
Seemed to do the job. Now-a-days, I guess the new fangled thing is to mount /tmp as tmpfs file system and it gets emptied on every reboot? |
Not too familiar with tmpfs, but a Linux machine might well not be 'rebooted' for months at a time . . .
|
The tmpreaper program can be used to clean up /tmp periodically. This program deletes everything that has not been accessed in a given timeframe, typically two weeks. For this to work properly, the filesystem it is on should have the atimes option enabled. If you use a tmpfs, which it appears you are doing, then you should be fine.
Of course, rebooting also clears /tmp, but that would be boring. |
All times are GMT -5. The time now is 07:16 AM. |