The Dspam database gets very big after a while because it’s stores all the important stuff of all the emails that pass through it. All the keywords and the status of the email is stored and if you receive a lot of mail that database grows considerably. To keep the information in the Dspam database fresh and the system nimble we need to purge the database every now and then.

This removes all the the old keywords from the database, being older than 90 days and not seen after that. This means that the nuber of keywords that are checked are kept to a certain limit. This purging helps to improve the accuracy of the spam filter as it no longer checks on keywords no longer in use.

To purge the database every now and then you need to follow the next steps:

From the dspam source archive copy the purge file to ‘/usr/local/var/dspam/

sudo cp src/tools.mysql_drv/purge-4.1.sql /usr/local/var/dspam/

Create a script called ‘dspam.purge‘ in the location ‘/etc/periodic/weekly‘ to have the script executed on a weekly basis. The content of the file should look like:

#!/bin/sh -
export PATH
echo “Purging the Dspam database”
$MYSQL –password=dspampassword dspam –user=dspamuser < /usr/local/var/dspam/purge-4.1.sql

Don’t forget to change the userid and password to those you have configured for your database and you have to make the script executable by using the following command:

sudo chmod +x /etc/periodic/weekly/dspam.purge

Dspam should be performing better now on the long run.