这是清除exim邮件队列的正确方法吗?

Man*_*ani 4 linux email exim cpanel

我使用以下命令删除exim邮件队列

exiqgrep -i | xargs exim -Mrm
Run Code Online (Sandbox Code Playgroud)

或者

# following commands seems to work faster compared to the above.
exim -bpru | awk {'print $3'} | xargs exim -Mrm
Run Code Online (Sandbox Code Playgroud)

但是当邮件队列大小超过 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
Run Code Online (Sandbox Code Playgroud)

小智 5

我相信你正在寻找这个......

service exim stop
rm -fvr /var/spool/exim/input
service exim restart
Run Code Online (Sandbox Code Playgroud)

然而,稍微更理智的方法是基于每个用户删除消息......

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 
Run Code Online (Sandbox Code Playgroud)