[Mimedefang] cron script to archive MD-Quarantine

Rob MacGregor rob.macgregor at gmail.com
Wed Sep 29 14:21:26 EDT 2004


On Wed, 29 Sep 2004 10:01:15 -0700, matthew.van.eerde at hbinc.com
<matthew.van.eerde at hbinc.com> wrote:
> Has anyone already done something like this and is willing to share code?  Or perhaps has another approach?

Ok, as follows, watch the line wraps:

purge_md()
        {
        BASE=/var/spool/MD-Quarantine   # Where the quarantined emails are held
        COUNT=0                 # Number of emails purged

        if [ ! -d ${BASE} ]; then
                echo "Error: MIME Defang not installed"
                exit
        fi

        find ${BASE} -ctime +${AGE} -type d -print | egrep -v
"^${BASE}$" | while read DIR
                do
                if [ -d "${DIR}" ]; then
                        rm -fr ${DIR}
                        COUNT=`expr ${COUNT} + 1`
                fi
                done

        if [ ${COUNT} -gt 0 ]; then
                echo "Purged ${COUNT} virus infected emails over
${AGE} days old."
        fi
        }

This is a function from a larger (bash) script, which manages a number
of different quarantine directories (clamav-milter, amavis and MD)
with a centrally defined $AGE.

I run this nightly, so that there isn't a sudden hammering of the
system once a month (or whatever).  It would be easy enough to tweak
it to create a tar.bz2 instead of deleting.

-- 
Rob MacGregor

Whoever fights monsters should see to it that in the process he 
        doesn't become a monster.
                                                   Friedrich Nietzsche



More information about the MIMEDefang mailing list