Operating Systems > Lunix & Unix

Empty Postfix Mail Queue

(1/1)

admin:
Empty Postfix Mail Queue

This command will delete one specific email from the mailq (taken from the postsuper man page)

--- Code: ---mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 == "email@address.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
--- End code ---

I use a few scripts that check the status of our servers and email/page me if they don't respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy:

--- Code: --- sudo postsuper -d ALL
--- End code ---


This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use 'man postsuper' to find out all of the available options.


The other thing that helped with this was checking for a local network connection before doing the server checks. This is done with the following.

--- Code: ---ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'}L
--- End code ---

Navigation

[0] Message Index

Go to full version