Search

Enter a search word or two and press return to see the search results.

Who am I?

Hi, I’m Graeme and these are my notes, from my messy desk. I started this blog because Google proved to be more useful at finding content than anything else I’ve used.

So I started adding my own content in the hopes that Google would index it and allow me to find things again in the future.

It works.

You can find out more about me here, and you should follow me on Twitter here.

Keeping up

You can automatically receive new content here by subscribing to the “Blog RSS” (link below). This is the easiest way to keep up with what I write here.  See this BBC article for a good introduction on RSS and keeping up with the goings on of the Internet more easily.

« Sauce with Postfix | Main | Duplicate suppression in procmail »
Wednesday
15Oct2003

Cleaning out the (Postfix) mail queue

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 -d


It'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...

PrintView Printer Friendly Version

EmailEmail Article to Friend

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

December 1, 2006 | Unregistered CommenterMike

A spambot utilizing a clients email is clogging my ques.

Thanks for taking the time to post this solution

it worked great

April 25, 2008 | Unregistered CommenterMark Hogben

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>