quick tip: rotating tomcat logs via cronolog

1.compile cronolog (http://cronolog.org) and install it on /usr/local/sbin
2. backup orig /usr/local/apache-tomcat-5.5.20/bin/catalina.sh  on /root
3. edit lines on catalina.sh from
org.apache.catalina.startup.Bootstrap “$@” start \
>> “$CATALINA_BASE”/logs/catalina.out 2>&1 &

to

org.apache.catalina.startup.Bootstrap “$@” start 2>&1 \
| /usr/local/sbin/cronolog “$CATALINA_BASE”/logs/catalina.out.%Y-%m-%d >> /dev/null &

4. Removed the line
touch “$CATALINA_BASE”/logs/catalina.out

5. Restart web service
#/usr/local/tomcat/bin/shutdown.sh
# service httpd stop
# /usr/local/tomcat/bin/startup.sh
#service httpd start

TESTING

1.    Check tomcat logs to see generated Catalina.out per day
# ls -la /usr/local/tomcat/logs

-rw-r–r–   1 root root      65607 Nov  6 14:55 catalina.out.2007-11-06

2.    browse ww2.freelinuxtutorials.com and login using test account to see if tomcat is working

FALLBACK

1.    copy original Catalina.sh file to the location
2.    cp /root/catalina.sh /usr/local/apache-tomcat-5.5.20/bin/
3.    restart web
#/usr/local/tomcat/bin/shutdown.sh
# /usr/local/tomcat/bin/startup.sh
#service httpd restart

About the author

tux

View all posts

Leave a Reply