Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a private postfix relay VPS which is used by customers where they've installed their own e-mail servers in their offices and hosted over their ADSL connection. In the interests of reliable e-mail delivery, it's really not recommended to send mail directly from ISP IP addresses so I offer them the ability to use our private relay. However one of these customers has decided to send a newsletter to 5,000 recipients. I caught this straight away and dumped them all into the hold queue.

But now I'd like to try and flush this queue in batches, starting with the oldest messages.

Anyone got any ideas how to do this?
It looks like it would be a monster of a shell script to grep through the output of postqueue -p

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

If you have an idea of how old the oldest message is, you could do it with some grep and awk magic. I.e., if the oldest message is from Fri Jul 13, you could do this:

postqueue -p |grep "Fri Jul 13"|head -5000 | awk '{print "postsuper -I", $1}'|sh

to take the first 5000 messages found for that date. This doesn't do any sorting on which time during that date the mail was sent, if you want that, you could just add the hour for each hour.

share|improve this answer
    
That's brilliant. I need to learn awk! –  benbradley Jul 18 '12 at 9:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.