Thursday, January 15, 2009

Rotate log files

If there is no inbuild mechanism to rotate log files in an application, you can use logrotate.
Put something like this in /etc/logrotate.d in a file.
/opt/tomcat/logs/catalina.out {
rotate 14
size 5M
copytruncate
compress
postrotate
# reset ownership to comply with directory's permissions
chown vgnadmin:webops /opt/tomcat/logs/catalina.out.*
endscript
notifempty
missingok
}