Logrotate files with date in the file name

后端 未结 11 862
孤城傲影
孤城傲影 2020-12-13 05:08

I am trying to configure logrotate in RHEL for tomcat6 logs. Currently, logrotate works fine for catalina.out log, it is rotated and compressed properly.

The problem

11条回答
  •  悲哀的现实
    2020-12-13 05:35

    Something like this in /etc/cron.d/rotate_tomcat_logs:

    # delete every log file over 100 days old, and compress every log file over 1 day old.
    00 1 * * * root ( find /opt/tomcat/logs -name \*log\* -name \*.gz -mtime +100 -exec rm -f {} \; >/dev/null 2>&1 )
    05 1 * * * root ( find /opt/tomcat/logs -name \*log\* ! -name \*.gz -mtime +1 -exec gzip {} \; >/dev/null 2>&1 )
    

提交回复
热议问题