Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Delete all queued messages containing a certain string in the body  (Read 2091 times)

0 Members and 1 Guest are viewing this topic.

Aby

  • Guest
Delete all queued messages containing a certain string in the body

Code: [Select]
root@localhost# grep -lr 'a certain string' /var/spool/exim/input/ | \
sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm

Note that the above only delves into /var/spool/exim in order to grep for queue files with the given string, and that's just because exiqgrep doesn't have a feature to grep the actual bodies of messages. If you are deleting these files directly, YOU ARE DOING IT WRONG! Use the appropriate exim command to properly deal with the queue.

If you have to feed many, many message-ids (such as the output of an `exiqgrep -i` command that returns a lot of matches) to an exim command, you may exhaust the limit of your shell's command line arguments. In that case, pipe the listing of message-ids into xargs to run only a limited number of them at once. For example, to remove thousands of messages sent from User1@example.com:

root@localhost# exiqgrep -i -f '<user1@example.com>' | xargs exim -Mrm

-----
« Last Edit: April 21, 2014, 06:28:06 pm by Aby »