This details my attempts at setting up logrotation on CentOS 5 for Tomcat when installed from the Loway repo. I believe this is an oversight in the Loway Tomcat deployment and I have
created a feature request for this.
If you would like to setup Tomcat logrotation you can do the following:
# vi /etc/logrotate.d/qm-tomcat6
/usr/local/queuemetrics/tomcat/logs/*.log {
notifempty
copytruncate
daily
size=+1024k
rotate 10
compress
missingok
}
/usr/local/queuemetrics/tomcat/logs/catalina.out {
notifempty
copytruncate
dateext
daily
size=+1024k
rotate 10
compress
missingok
}
If you want to get fancy you can make it take care of cleaning out temp files as well (or just do it from cron as you would normally)
/usr/local/queuemetrics/tomcat/logs/catalina.out {
notifempty
copytruncate
dateext
daily
size=+1024k
rotate 10
compress
missingok
postrotate
/bin/nice /usr/bin/find /usr/local/queuemetrics/tomcat/temp -type f -mtime +10 -exec /bin/rm {} \; > /dev/null
endscript
}
UPDATE: I have subsequently added
size=+1024k to my suggestion as this seems to get past the logrotate.conf issues of only rotating logs weekly so you no longer have to follow the steps below (unless you want all your other system logs to rotate daily as well).
I also took some time to delve into the CentOS logrotation settings and would suggest some of the following changes depending on your needs. I found that even if I set the rotation to daily in qm-tomcat6 logrotate.conf overrides it to weekly.
# vi /etc/logrotate.conf
Set weekly to daily
# rotate log files daily
daily
Change the backlogs from 4 week to 14 days
# keep 14 days worth of backlogs
rotate 14
I like compressed logs
# uncomment this if you want your log files compressed
compress
By default logrotation runs at 4am. You can change this by editing /etc/crontab
Set it to 02:02
02 2 * * * root run-parts /etc/cron.daily
Additional reading:
http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-centos-part-1http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-centos-part-2Comments, suggestions and improvements welcome!