Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to delete some messages from an existing postfix queue based on a string match in the message body. Any suggestions?

share|improve this question
up vote 9 down vote accepted

This is fairly simple:

find /var/spool/postfix/deferred/ -type f \
        -exec grep -l 'body string here' '{}' \; | \
    xargs -n1 basename | xargs -n1 postsuper -d

Adjust path (if non-default), and the -n1 in the second xargs isn't strictly needed, but gives a better sense that it's actually doing something.

share|improve this answer
    
He didn't specify which queue. – adaptr Apr 25 '12 at 8:17
2  
True. For a different queue, use that instead of deferred in the find portion. postsuper works on a number of queues -- hold, incoming, active and deferred -- or you can specify it at the end ( ... | xargs -n1 -i postsuper -d '{}' bounce ) – techieb0y Apr 27 '12 at 1:09

Perhaps you should end that with > delfile.txt then you can review what you deleted and then delete the text file

share|improve this answer

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.