One thing that has always annoyed me in Slackware is that /tmp never gets automatically cleared so I end up with with lots of space wasted in there. Especially after building lots of SlackBuilds and filling up /tmp/SBo :). I sometimes looked in there to clean it up manually and hope I don't delete something that's in use, but that gets boring pretty quickly. So I finally decided to look at a way to clean it up automatically, and it's as simple as adding a line to /etc/rc.d/rc.local_shutdown
. That line is
# cleanup tmp
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -mtime +7 -exec /bin/rm -rf {} +;
This will remove anything recursively in /tmp which hasn't been used (or modified) for at least 7 days. If you want to change the number of days to keep files you can change the +7 on the -mtime option.
If you don't already have a /etc/rc.d/rc.local_shutdown
then you can just create it and chmod +x rc.local_shutdown
then it will automatically be run during system shutdown.
Grav was with by Trilby Media.