Why ?
In
Linux one of the great feature that you can manage and organize any log file to
be rotated on any criteria , for example if you have web service that will
create a file.log and you want to have instead a daily file and nominated with
that date , or/and have a specify size and/or number of files ..etc , you may
use logrotate feature to achieve this.
How ?
Below
are sample script to rotate a catalina.out file which is the main tomcat log
file in daily bases and compress it and keep it for one year, the new file will
be date only and orginal file will be kept same as it ,:
1- may use man to check all features of logrotate:
man logrotate
2-
create the configuration file under logrotate.d :
vi /etc/logrotate.d/tomcat
/<path_to_logs>/catalina.out
{
su user group
copytruncate
compress
daily
missingok
delaycompress
dateext
maxage 365
}
3- You may force the logrotate to run immediately
instead of wait for next day.
logrotate –fv /etc/logrotate.d/tomcat
No comments:
Post a Comment