创建这样的脚本是否有意义,或者假脱机文件是否可能被破坏?
我希望能够将最大邮件假脱机文件大小控制为500MB或保留一个月,然后将其余内容归档,以先到者为准:
/var/spool/mail/* {
monthly
size 500M
missingok
rotate 24
notifempty
sharedscripts
}
答案 0 :(得分:0)
我没有使用logrotate。我所做的是将假脱机文件重定向到/ dev / null以清除它们。我之前也停止了我的电子邮件服务,并在清理后启动它。您可以根据需要定制
echo "emailclean.sh starting on $(date)"
echo "Stopping fetchmail service"
#/sbin/initctl stop <service>
pkill fetchmail
sleep 10
echo "Cleaning up old mail"
cat /dev/null > /var/spool/mail/root
cat /dev/null > /var/spool/mail/webalert
sleep 10
echo "Starting fetchmail Service as user webalert"
sudo -u webalert /usr/bin/fetchmail
#/sbin/initctl start <service>
echo "Cleanup Complete! /var/spool/mail/root and webalert files sent to dev0"
echo "emailclean.sh finished cleanup on $(date)"