大网数据广告活动
服务器运维问答

How to Clear/Reset a Postfix Queue

· 52CE 我爱测

I recently discovered that one of our Ubuntu servers was generating dozens of notification emails a minute and throttling the Office 365 relay account it was sharing with a handful of other servers. I stopped the Postfix service …

问题原文

原帖链接 · Beady Eye T · CC BY-SA 4.0

I recently discovered that one of our Ubuntu servers was generating dozens of notification emails a minute and throttling the Office 365 relay account it was sharing with a handful of other servers. I stopped the Postfix service on this server and disabled the scripts that were generating all of these alerts (and subsequent cascade of delivery failure messages). However, I didn't account for the Postfix Queue Manager which has retained thousands of these messages and attempts to send them all over again when I restart Postfix.

My first, admittedly bumbling, attempt to clear the queue was to navigate to the queue directory at /var/spool/postfix and manually remove files from the 'active' and 'incoming' folders. However, when I ran postqueue -p a ton of emails still showed up in the queue.

What is the best way to completely reset or purge a Postfix Queue?

已采纳解答

原帖链接 · Guss · CC BY-SA 4.0

You should use the postsuper command to delete messages from the Postfix queue - The -d <queueid> option would delete the message with the specified queue ID.

I'm using something like this script to run through all the messages in the mail queue:

mailq | awk '$7~/@/{print$1}' | while read qid; do postsuper -d $qid; done

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-12-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。