Script to reboot in case of too many MailScanner crashes

Denis Beauchemin Denis.Beauchemin at
Fri Aug 26 18:53:31 UTC 2016


Some time ago I wrote this script to reboot one server if there were more than 3 MailScanner crashes since the last reboot. I did this because I had MailScanner flag all emails as causing a crash. Rebooting the server solved the problem (but not restarting the service). I run this script in root’s crontab every 5 minutes:

NB_ERRS=$(egrep "it has been attempted too many times|clamd daemon|clamd.*: Self checking every 600 seconds|aliases rebuilt by root|dccifd for ASCII protocol" /var/log/maillog|awk 'BEGIN{nb=0}/Warning: skipping message/{nb++;next}{nb=0;next}END{print nb}')

if [[ "$NB_ERRS" -gt 3 ]]; then
        echo "Rebooting $(hostname -s): $NB_ERRS errors found since last reboot!"
        echo "OK: $NB_ERRS errors found since last reboot"

The script will reset its count of MS crashes if it finds the server rebooted after the crashes.

It worked fine on my RHEL 6 servers.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the MailScanner mailing list