wiki:expire-quarantine-cache.pl

Version 2 (modified by rjl, 14 years ago) (diff)

--

The expire-quarantine-cache.pl script

Maia Mailguard system encourages the end-users to manage their own quarantine areas and ham caches on a regular basis, to make sure no legitimate mail has been held up in quarantine, and so on. That said, not all users will be diligent about checking their quarantine areas in a timely manner, and if left untended, this can result in a lot of wasted storage space.

By setting the expiry period for quarantined items and cached ham from Maia Mailguard's System Configuration page, and running this script from a daily cron job, you can force the expiry of quarantined items that have not been dealt with in a certain amount of time, to make sure they don't sit in your database indefinitely.

Schedule this script to run once per day, preferably at an off-peak time. It will check the ages of all unconfirmed spam and ham in the quarantine/cache, and delete items that are older than your specified thresholds. The thresholds themselves are set by the superadministrator from the System Configuration page.

The available command-line options are:

--suspected-nonspam    : expire Suspected Non-Spam items
--nosuspected-nonspam  : don't expire Suspected Non-Spam items
--suspected-ham        : same as --suspected-nonspam
--nosuspected-ham      : same as --nosuspected-nonspam
--suspected-spam       : expire Suspected Spam items
--nosuspected-spam     : don't expire Suspected Spam items
--viruses              : expire Virus/Malware items
--noviruses            : don't expire Virus/Malware items
--bad-headers          : expire items with Invalid Mail Headers
--nobad-headers        : don't expire items with Invalid Mail Headers
--banned-files         : expire items with Banned File Attachments
--nobanned-files       : don't expire items with Banned File Attachments
--banned-attachments   : same as --banned-files
--nobanned-attachments : same as --nobanned-files
--confirmed-nonspam    : expire Confirmed Non-Spam items
--noconfirmed-nonspam  : don't expire Confirmed Non-Spam items
--confirmed-ham        : same as --confirmed-nonspam
--noconfirmed-ham      : same as --noconfirmed-nonspam
--confirmed-spam       : expire Confirmed Spam items
--noconfirmed-spam     : don't expire Confirmed Spam items
--help                 : display this help text
--debug                : display detailed debugging information
--quiet                : display only error messages

The /etc/maia.conf file lets you specify what exactly the expire-quarantine-cache.pl script should expire:

# Mail types to expire (add values together as desired):
#    0 = none (don't expire anything)
#    1 = expire Suspected Non-Spam
#    2 = expire Suspected Spam
#    4 = expire Viruses/Malware
#    8 = expire items with Invalid Mail Headers
#   16 = expire items with Banned File Attachments
#   32 = expire Confirmed Non-Spam
#   64 = expire Confirmed Spam
$mail_types = 1 + 2 + 4 + 8 + 16;

$mail_types saves you the trouble of having to combine a whole bunch of command-line options; any command-line options you specify will override this setting, however. In most cases a value of 31 (1 + 2 + 4 + 8 + 16) is what you'll want. Expiring confirmed spam/non-spam is something the process-quarantine.pl script is supposed to do after it finishes training the Bayes database and reporting spam, so if your system is in good working order there should never be any of these items for the expire-quarantine-cache.pl script to deal with. If you've forgotten to run the process-quarantine.pl script for a few weeks, though, you may just want to expire those items rather than choke your system trying to learn and report thousands of mail items. In that case, the --confirmed-ham and --confirmed-spam options may be called for.