Oct 30, '03 09:59:00AM • Contributed by: Peter Kappesser
I discovered that my Jaguar partition was slowly getting filled up by accumulated cruft that was not being dealt with by the periodic maintenance scripts (see the man periodic manual page for more info). For example, if you don't have sendmail enabled, any cron jobs that produce output or errors will write files to /var/spool/clientmqueue that never get used. I found about 100 MB of files there. Similarly, the cups system leaves files in /var/spool/cups. If you run HenWen (the snort network intrusion detection system), its log files accumulate in /var/log/snort -- up to a few megabytes' worth per day, depending on settings.
I use the following script to remove these extra, stale files. You can adjust the time limits in the find lines to suit your preferences.
#! /bin/sh # extended daily cleanup script # save as /etc/daily.local ## stale sendmail: /usr/bin/find /var/spool/clientmqueue -mtime +7 -delete ## cups cruft: /usr/bin/find /var/spool/cups -mtime +7 -delete ## snort stuff: /usr/bin/find /var/log/snort -mtime +30 -delete ## BBEdit backups: ## Fill in the path to your backup directory below and uncomment the line #/usr/bin/find [path to BBEdit backup] -mtime +365 -delete
I suggest creating the file wherever you like on your own account, then copy it:
The sudo takes care of the permissions for the file and directory, plus you keep your own copy of the file in case the one in /etc gets zapped by a system upgrade or reinstall. I didn't put the script in /etc -> periodic -> daily because, according to the periodic man page, user-supplied scripts must return a precise exit status and that was overkill for what I needed to do.
sudo cp daily.local /etc