Clearing postfix mail queue by domain

Clearing postfix mail queue by domain

Linux, Postfix, Servers, Slider No Comments on Clearing postfix mail queue by domain

Recently my phone started frantically beeping with the mail servers hard drive filling up and CPU load through the roof.

After eventually managing to login, stopping postfix the CPU came under control.

20 mins of waiting for the queue to open up and it shows 30,000 pending emails – ahhhhh!

28,500 of those were from a single domain, it appears 4 accounts from one of our clients have moved to Eastern Europe and gone on an email spree.

Webmin wouldn't be up to the task of clearing these so I needed a shell command that could clear everything by domain name.

The solution that did the job is below.

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / *@example\.com/ { print $1 }' | tr -d '*!' | postsuper -d –

Mark Walker

Related Articles

Leave a comment

You must be logged in to post a comment.

A collection of tips, tricks, reviews and discussion created by webmasters for webmasters.


Back to Top