/var/spool/mail/*上的logrotate邮件脚本



创建这样的脚本有意义吗?或者假脱机文件可能会损坏吗?

我希望能够将最大邮件假脱机文件大小控制在500MB,或者将其保留一个月,将其余文件存档,以先到者为准:

/var/spool/mail/* {
monthly
size 500M
missingok
rotate 24
notifempty
sharedscripts
}

我没有为此使用logrotate。相反,我所做的是将spool文件重定向到/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)"

最新更新