There is no mention of cleaning up the Exim db, not on the cPanel site or in any of their documentation. Most of you, like it did, will find lots and lots of junk e-mail messages sitting around in your Exim db that cannot be delivered to the recipient for some reason or another. The end result is a bunch of messages in the your exim_mainlog showing as RETRY, UNDELIVERABLE, SMTP TIMEOUT etc. But you can cleanup that junk by following the instructions below;

First you should execute the following commands from your command line, as root before you add the cron entries below. This cleans up your db now, and free’s up the junk in your db’s.

Copy and paste these commands, one line at a time, to the command line, then press enter. Watch the junk dissappear. You will see loads of junk being deleted. A good thing! If you cPanel installation is relativly new you will see a few messages being removed. If your cPanel installation is more mature you may see hundreds of messages being removed.

/usr/sbin/exim_tidydb -t 1d /var/spool/exim retry
/usr/sbin/exim_tidydb -t 1d /var/spool/exim reject
/usr/sbin/exim_tidydb -t 1d /var/spool/exim wait-remote_smtp

After you have cleaned up your db, place these commands in a cron, that runs at say 5:30am everyday. Thats a good time to do it since email usage is probably at the lowest. Find out what time email usage is at the lowest on your server and change it from 5:30am to whatever time you want. Execute once per day is fine.

The following cron entry removes all junk msgs if they are more than 1day old.

pico /etc/crontab and add these entries;

# Clean up the Exim retry database at the quietest time of day.
25 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim retry
30 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim reject
35 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim wait-remote_smtp

If you are running MailScanner place these entries in your crontab instead. Do not add these entries if you are not using MailScanner.

# Clean up the Exim retry database at the quietest time of day.
25 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim_incoming retry
30 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim_incoming reject
35 5 * * * root /usr/sbin/exim_tidydb -t 1d /var/spool/exim_incoming wait-remote_smtp

Report back with how much junk was deleted

Thats it!

Leave a Reply