Archive

Archive for May, 2013

How To remove all messages from a sendmail mail queue

 
Problem description:

Somehow your sendmail outgoing message queue got flooded by e.g. a job and you want to remove all of the messages to be delivered.

 
Problem resolution:

Outgoing messages in the sendmail queue are stored in /var/spool/mqueue. In order to get an overview of the messages you could execute the following sendmail command:

sendmail -bp

 
As your sendmail queue got flooded with a lot of messages, this command might take forever. So instead of querying all of the stored messages you can also check the files directly:

[root@server01 mqueue]# pwd
/var/spool/mqueue
[root@server01 mqueue]# 

[root@server01 mqueue]# ls -al
...
-rw-------  1 root smmsp    1285 18. Mai 10:35 qfr4I8ZSBn009790
-rw-------  1 root smmsp    1242 18. Mai 10:35 qfr4I8ZSu1009786
-rw-------  1 root smmsp    1233 18. Mai 10:35 qfr4I8ZumY009830
-rw-------  1 root smmsp    1253 18. Mai 10:35 qfr4I8ZUOF009794
-rw-------  1 root smmsp    1257 18. Mai 10:35 qfr4I8ZXPu009798
-rw-------  1 root smmsp    1253 18. Mai 10:35 qfr4I8ZZhj009802
...
[root@server01 mqueue]# 

[root@server01 mqueue]# ls -al | wc -l
34439
[root@server01 mqueue]#

 
There is no explicit command for removing all messages. You can directly delete them with “rm”. In order to remove all messages, we just delete the queued files:

[root@server01 mqueue]# pwd
/var/spool/mqueue
[root@server01 mqueue]# 

[root@server01 mqueue]# rm -f *
[root@server01 mqueue]# 

[root@server01 mqueue]# ls -al
insgesamt 1128
drwx------  2 root mail 1138688 20. Mai 11:06 .
drwxr-xr-x 16 root root    4096 11. Mai 2011  ..
[root@server01 mqueue]#

 
“sendmail -bq” should now report an empty mail queue:

[root@server01 mqueue]# sendmail -bp
/var/spool/mqueue is empty
          Total requests: 0
[root@server01 mqueue]#

 

Categories: Uncategorized Tags: