我正在尝试从根我的脚本删除 sendmail 消息,该脚本将要删除的邮件消息删除到具有尊重 id 的文件中,但即使从根目录运行它仍然没有删除它。所有它都说权限被拒绝不能删除文件,甚至从根本上
#!/usr/bin/ksh
WORKFILE="/tmp/check.mq"
MAILLIST="emailadress"
mailq|grep -B1 -i temporarily |grep -iv deferred |egrep -i 'jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec' |awk -F" " '{print $1}' |awk '{print substr($0,10,14)}' |tee -a $WORKFILE |awk '{print "*" $1}' |tee -a mail.mq
mailq|grep -B1 -i unknown|egrep -i 'jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec' |awk -F" " '{print $1}' |awk '{print substr($0,10,14)}' |tee -a $WORKFILE |awk '{print "*" $1}' |tee -a mail.mq
mailq|grep -B1 -i lookup |grep -iv deferred |egrep -i 'jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec' |awk -F" " '{print $1}' |awk '{print substr($0,10,14)}' |tee -a $WORKFILE |awk '{print "*" $1}' |tee -a mail.mq
cat mail.mq | while read file; do rm -rf /var/spool/mqueue/$file;done
find . -type f -name "mail.mq" |rm -rf mail.mq
我正在使用此代码记下 id,然后对 id 的最后 5 个数字进行子串化。
我得到的错误是
rm: cannot lstat '/var/spool/mqueue/*11343' :Permission denied
我被拒绝删除这些邮件