Tag Archives: scripts

Clean up /tmp

Recently I noticed that there’s a lot of temporary files in the /tmp directory on my mail server … all the files have spamassassin in the file name. I figured that in some cases, SpamAssassin (or programs it calls) isn’t cleaning up properly.

I whipped up this script that will clean up any spamassassin files & directories that are older than a set number of minutes (60 in my case)…



if [ "$1" == "--test" ]
        CMD="-exec echo"
        echo "$0: test mode"

/usr/bin/find /tmp \
        -mmin +$AGE \
        -name spamassassin.ocr* \
        $CMD /bin/rm -f '{}' \;

/usr/bin/find /tmp \
        -maxdepth 1 \
        -mmin +$AGE \
        -type d \
        -name .spamassassin\* \
        $CMD /bin/rm -rf '{}' \;

If you run the script with a parameter of ‘–test’, it will just show the commands it would have executed.

I put the script in /etc/cron.hourly directory so it gets executed every hour.

Related posts ...
Fair warning: This post is pretty darn technical and is of little interest to people
I put together a new SpamAssassin rule that will help identify spam from spoofed email
Running SpamAssassin after a Fedora Core 6 update results in "Use of uninitialized value in
A while ago I added a new anti-spam technique to my mail server setup called