先到 /etc/logrotate.d 目錄底下
# cd /etc/logrotate.d # touch dovecot # nano dovecot
然後編輯這個檔案,寫上
/var/log/dovecot*.log {
weekly
missingok
copytruncate
rotate 7
compress
notifempty
sharedscripts
postrotate
if [ -f /var/run/dovecot/master.pid ]; then \
/etc/init.d/dovecot reload > /dev/null 2>&1 || true ; \
fi;
endscript
}
存檔,這樣系統就可以自動每週幫 /var/log/dovecot.log Logrotate 一次了。如果要測試一次,可以手動讓 logrotate 執行一次
# logrotate -vf /etc/logrotate.conf
這樣就可以知道這個腳本是否有正確運行。