logrotate is a powerful system software, it has a complete set of operating mode for log files, such as: Dump, mail and compression, and the default logrotate
added to Cron ( /etc/cron.daily/logrotate ) as daily task execution. Automatically with logrotate, I don't want to write my own log cutting scripts.
the following Tomcat Log Catalina.out Log Cutting
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7C/CB/wKiom1bX9tugiULbAAFFNx9JtXk148.png "title=" 4.png " Style= "Float:none;" alt= "Wkiom1bx9tugiulbaaffnx9jtxk148.png"/>
the following Tomcat Log Catalina.out Log Cutting
Ls-lh/usr/local/tomcat/logs/catalina.out
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7C/CB/wKiom1bX9trDbUOKAAAkqjDeBPM203.png "style=" float: none; "title=" 1.png "alt=" Wkiom1bx9trdbuokaaakqjdebpm203.png "/>
# Cat/etc/logrotate.d/tomcat
/usr/local/tomcat/logs/catalina.out {
Daily
Rotate 5
Missingok
Dateext
Compress
Notifempty
Copytruncate
}
Detailed parameters:
Daily Specify a dump cycle of daily
Rotate 5 specifies the number of times the log file was dumped before it was deleted . 0 means no backup, 5 means reserved 5 a backup
Missingok Ignore this warning message if the log does not exist
Dateext file suffix is date format , that is, after the cut file is : xxx.log-20150828.gz
Compress through gzip compress dumps after the log ( gzip-d xxx.gz decompression)
Notifempty If it is an empty file, do not dump
copytruncate for log files that are still open, put the current log Backup and truncation
Truncate log immediately:
# logrotate--force/etc/logrotate.d/tomcat
# Ls-lh/usr/local/tomcat/logs/catalina.out
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/CB/wKiom1bX9x3zQ_X6AAA0G4z0WOM591.png "style=" float: none; "title=" 2.png "alt=" Wkiom1bx9x3zq_x6aaa0g4z0wom591.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/CA/wKioL1bX95fCA60ZAAAhaFX2ovI450.png "style=" float: none; "title=" 3.png "alt=" Wkiol1bx95fca60zaaahafx2ovi450.png "/>
Oh, later to view the Tomcat log is particularly convenient
This article is from the "Brother to share" blog, please be sure to keep this source http://renzhiyuan.blog.51cto.com/10433137/1747213
Tomcat Log Cutting