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

2 Answers 2

up vote 4 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
1  
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.