House-keeping in Linux
Checked your /tmp folder lately? You might be surprised how many files there are if you do not clean it on a regular basis. To keep mine tidy, I have a small script called 'cleantmp':
#!/bin/bash
find /tmp -atime +5 -exec rm -r {} \;
find /var/tmp -type f -atime +30 -exec rm {} \;
Basically it looks for files in /tmp that are at least five days old and removes them, including subdirectories.
In /var/tmp it allows the files to stay a bit longer: 30 days.
To keep your system clean as well, save this script in /usr/local/bin as 'cleantmp' (or any name you prefer), and make it executable with:
chmod +x /usr/local/bin/cleantmp
Now if your system stays on 24 hours a day, you can schedule this script from crontab:
ln -s /usr/local/bin/cleantmp /etc/cron.daily/cleantmp
But if you normally turn of your computer, you can call 'cleantmp' from /etc/rc.d/rc.local
Happy Slacking!
#!/bin/bash
find /tmp -atime +5 -exec rm -r {} \;
find /var/tmp -type f -atime +30 -exec rm {} \;
Basically it looks for files in /tmp that are at least five days old and removes them, including subdirectories.
In /var/tmp it allows the files to stay a bit longer: 30 days.
To keep your system clean as well, save this script in /usr/local/bin as 'cleantmp' (or any name you prefer), and make it executable with:
chmod +x /usr/local/bin/cleantmp
Now if your system stays on 24 hours a day, you can schedule this script from crontab:
ln -s /usr/local/bin/cleantmp /etc/cron.daily/cleantmp
But if you normally turn of your computer, you can call 'cleantmp' from /etc/rc.d/rc.local
Happy Slacking!
Labels: Linux, Maintenance
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home