Cleaning out the (Postfix) mail queue
Wednesday, October 15, 2003 at 2:04PM Due to our mail architecture, the main filter machine will wind up with a lot of messages from MAILER-DAEMON sitting in its queue which remote hosts are refusing to accept. Here is the command I use to clear out these messages:
mailq|awk ' /^[0-9A-F][0-9A-F]*[^*].*MAILER-DAEMON$/ {print $1}'|sudo xargs -rn1 postsuper -dIt's entirely specific to Postfix, of course. Note the [^*] there which will skip messages from MAILER-DAEMON that it's currently in the process of trying to deliver. I thought I'd share it with you because otherwise one of these days it's going to fall out of my ~/.bash_history and I'll have to figure it out again...
Geekery
Reader Comments (2)
I do something similar with a shell script, not a neat 1 liner like you. I'm trying to fix a friend's mail server that has over 141k messages in the queue right now. It takes almost an hour just to parse the mailq output. I wish there were a faster way to do this.
-M
A spambot utilizing a clients email is clogging my ques.
Thanks for taking the time to post this solution
it worked great