问题原文
原帖链接 · vincent.m · CC BY-SA 3.0
Sometimes, mails stay stuck in my postfix queue, the distant server saying "Too many connections, slow down". I already configured my postfix for specific domains to send only one mail per second, but sometimes it seems insufficient.
I know of postqueue -f, but it send all mails at the same time and the mails stays in queue with the same status.
I would like to flush the queue of a postfix one mail at a time, let's say one mail every second (or 2, or more).
已采纳解答
原帖链接 · Jenny D · CC BY-SA 3.0
It's possible to flush one particular email, instead of the whole queue. If you do this for each message in turn, with a two-second sleep between messages, that should do what you ask for.
First, you need to find the queue IDs of the mails in the queue. You can get this by using the command postqueue -p. Here's an example output:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6777D6E1E 3517 Mon Jan 25 03:03:02 [email omitted]
[email omitted]
69F6471CA 2820 Tue Jan 26 03:24:17 [email omitted]
[email omitted]
What you need is in the first column. You can get all of the IDs by some piping through grep and cut, like so:
[jenny@sameen ~]$ postqueue -p | grep -v ^- | grep -v "(" | cut -d' ' -f1 |grep -e [[:alnum:]]
6777D6E1E
69F6471CA
Now that you know how to get at the IDs, you can throw them in a bash loop with some sleep:
[jenny@sameen ~]$ for ID in `postqueue -p | grep -v ^- | grep -v "(" | cut -d' ' -f1 |grep -e [[:alnum:]] `; do postqueue -i $ID; sleep 2; done
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
