Automatically rotate Tomcat logs

1. Create or edit this file

 /etc/logrotate.d/tomcat 

2. Copy the following contents into the above file

 /media/emsites/SITE/11/tomcat/logs/catalina.out { copytruncate daily rotate 7 compress missingok size 100M } /media/emsites/SITE/11/tomcat/logs/catalina*.log { copytruncate daily rotate 7 compress missingok size 10M } /media/emsites/SITE/11/tomcat/logs/localhost*.txt { copytruncate daily rotate 7 compress missingok size 10M } 

Options:

daily - rotates the catalina.out daily.
rotate – keeps at most 7 log files.
compress – compresses the rotated files.
size – rotates if the size of catalina.out is bigger than 100M.
copytruncate – truncates the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one.

Launch logrotate manually:

 /usr/sbin/logrotate /etc/logrotate.conf