Friday, November 11, 2016

Rotate Tomcat catalina.out (If catalina.out becomes bulky in size, tomcat crashes and fails to start without any error message)

Rotate Tomcat catalina.out

If catalina.out becomes bulky in size, tomcat crashes and fails to start without any error message. 

To avoid this scenario you should rotate catalina.out frequently. 

Step - 1)
create file [any directory] with name "tomcatrotate"

Step - 2)
add content

/opt/apache-tomcat-7.0.67/logs/catalina.out  {
compress
copytruncate
daily
dateext
dateformat %Y-%m-%d
extension .out
missingok
rotate 14
size 100k
su root root
}

Step – 3)
after move to - /etc/logrotate.d/
sudo cp -i /home/minesh/Downloads/tomcatrotate /etc/logrotate.d/

Step - 4)
change the permission 777 to 644
sudo chmod -R 644 lportal

Step – 5)
after this test with below command it will do empty catalina.out and create its catalina2016-11-11.out.gz.

sudo /usr/sbin/logrotate -vf -s /var/log/logrotate-status /etc/logrotate.d/tomcatrotate

special thanks : https://masterinwebdev.blogspot.in/2016/11/tomcat-catalina.html