Topic: Tip: How to clear large sendmail queue

Sendmail generally stores its mail queue in /var/spool/mqueue. Queued messages are messages, that haven't reached their final destination yet. You can you may encounter with situation when the quota issues were not checked properly resulted in large mqueue with deferred mails flagged as permanently queued. If there are thousands of deferred mails in your mqueue folder then Sendmail can run slowly and eat a lot of CPU.

If you try to delete deferred mails, you will get an error:

[root@local /var/spool/mqueue]# rm *
/bin/rm: Argument list too long.

So if sendmail is having problems, after stopping it you might want to move the current queue directory to someplace else, to be processed specially. This is simple enough:

#mv /var/spool/mqueue /var/spool/mqueue-fixme
#mkdir /var/spool/mqueue
#chmod 755 /var/spool/mqueue
#chown root:daemon /var/spool/mqueue

Then purge mqueue contents:

#cd /var/spool/mqueue-fixme
#ls | xargs rm -f '{}'

And wait for a while... After that don't forget to start Sendmail.