Tar*_*rek 11 linux email-server postfix
我有一个带有多个域的服务器。如何清除特定域的所有 Postfix 队列消息?
seb*_*bix 18
更新 2021-04-18:
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 ~ /@example\.com/ && $9 == "") print $1 }' | tr -d '*!' | postsuper -d -
Run Code Online (Sandbox Code Playgroud)
而$7=sender, $8=recipient1, $9=recipient2。您还可以根据需要调整其他收件人 ( $9)的规则。
该命令基于postsuper 联机帮助页的示例,该示例命令匹配完整的收件人邮件地址:
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "user@example.com" && $9 == "") print $1 }' | tr -d '*!' | postsuper -d -
Run Code Online (Sandbox Code Playgroud)
旧内容:
此命令删除所有发自或发往以以下地址结尾的邮件@example.com:
sudo mailq | tail -n +2 | awk 'BEGIN { RS = "" } /@example\.com$/ { print $1 }' | tr -d '*!' | sudo postsuper -d -
Run Code Online (Sandbox Code Playgroud)
小智 7
我已经在 ubuntu 12.04 中尝试过这个解决方案,但它不能这样工作:
sudo mailq | tail +2 | awk 'BEGIN { RS = "" } / @example\.com$/ { print $1 }' | tr -d '*!' | sudo postsuper -d -
Run Code Online (Sandbox Code Playgroud)
我需要改成这样:
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /@example\.com/ { print $1 }' | tr -d '*!' | postsuper -d -
Run Code Online (Sandbox Code Playgroud)
解决方案
mailq | grep example.com -B1 | grep -oE "^[A-Z0-9]{10,11}" | sudo postsuper -d -
假设 ID 在 10 到 11 位之间,(基于 inode)
| 归档时间: |
|
| 查看次数: |
22275 次 |
| 最近记录: |