我使用以下命令删除 exim 邮件队列
exiqgrep -i | xargs exim -Mrm
或者
# following commands seems to work faster compared to the above.
exim -bpru | awk {'print $3'} | xargs exim -Mrm
但当邮件队列大小超过100,000时,上述命令不起作用。它被卡住了。因此,我使用以下脚本,无论队列中的邮件数量如何,该脚本都可以正常工作。
我的问题是,它会正确删除吗?
/etc/init.d/exim stop;
sleep 10;
killall -9 exim eximd
sleep 5;
#clean out the mail queue
find /var/spool/exim -mindepth 2 -type f -exec rm -rfv {} \;
#clean out the mail db files
find /var/spool/exim/db -type f -exec rm -rvf {} \;
/etc/init.d/exim restart
答案1
我相信你正在寻找这个...
service exim stop
rm -fvr /var/spool/exim/input
service exim restart
然而,一个稍微更明智的方法是根据每个用户删除消息......
egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr '\n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" '{gsub("-[A-Z]$","");print$NF}' | xargs exim -Mrm
答案2
即使队列中有数百万封电子邮件,我也取得了以下成功。
for i in $(exim -bp | awk '{print $3}'); do exim -Mrm $i; done
答案3
此外,要删除特定用户的电子邮件:
grep -lr '[email protected]' /var/spool/exim/input/ | \
sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | \
xargs exim -Mrm
exim -bp | \
grep "user_email-account" | \
awk '{print $3}' | \
xargs exim -Mrm
答案4
要从队列中删除所有消息,请输入:
# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash