Logrotate
如何檢查 logrotate 語法?
我們懷疑 /etc/logrotate.d/FOO 文件中有錯字。
我們如何檢查它?到目前為止,我可以看到:
https://linux.die.net/man/8/logrotate
也許這個?:
logrotate -df /etc/logrotate.d/FOO 2>&1 | grep -i error
之前可以使用標誌 -v 驗證 logrotate 語法
logrotate -vf /etc/logrotate.d/FOO
如果旋轉文件出現錯誤,它應該會出現。
我同意弗拉德對目前答案的評論。檢查語法的安全方法是使用調試選項。
來自
man logrotate
:-d, --debug Turns on debug mode and implies -v. In debug mode, no changes will be made to the logs or to the logrotate state file.
我的機器上的範例:
$ logrotate -d /etc/logrotate.d/httpd reading config file /etc/logrotate.d/httpd Handling 1 logs rotating pattern: /var/log/httpd/*_log 5242880 bytes (10 rotations) empty log files are not rotated, old logs are removed considering log /var/log/httpd/access_log log does not need rotating considering log /var/log/httpd/error_log log does not need rotating not running postrotate script, since no logs were rotated
當然,要實際看看會發生什麼,
-df
還是-vf
會強制旋轉,以便進一步分析。