Delete messages from a queue using omstat

From Scalix Wiki
Jump to: navigation, search

This is helpful if you get spammed and you need to delete a lot of messages from a queue. In situations like this, omqdump is slow and tedious. This method utilized the undocumented -j and -R switches for the omstat command.

I'll assume the messages are piled up on the service router. You can force this to happen by shutting down the router with "omoff -d0 -s router". If your messages have a subject of "Check this out" you could search for them and delete them as follows:

omstat -q router | grep "Check this out" | cut -d" " -f 1 | while read msgid
do
 omstat -q router -j -R -m $msgid
done

The above gets a list of message IDs for messages with a certain string in the subject, then it deletes those messages from the queue.

Be careful with this, because after the messages are deleted there is no way to recover them. You might want to run the first omstat/grep to ensure you're not accidentally getting some "good" messages in your list, then run the whole command.