Solve the problem of continuous accumulation of ES1en. out in Tomcat

  • 2020-10-23 21:17:57
  • OfStack

This method does not require modification of the Tomcat configuration pro test and is available

1. Add file clear_log.sh to tomcat bin

It is as follows:


#!/bin/sh
d=`date +%Y-%m-%d`
d7=`date -d'7 day ago' +%Y-%m-%d`
cp /opt/apache-tomcat-8.5.9/logs/catalina.out /opt/apache-tomcat-8.5.9/logs/catalina.${d}.log
echo "" > /opt/apache-tomcat-8.5.9/logs/catalina.out
rm -rf /opt/apache-tomcat-8.5.9/logs/catalina.${d7}.log

2. Add sh files to action permissions


chmod +x /opt/apache-tomcat-8.5.9/bin/clear_log.sh

3. Modify /etc/crontab file (timer) add to bottom of document (script to be executed at 01:00 per day) :


1 0 * * * root /opt/apache-tomcat-8.5.9/bin/clear_log.sh

Load the crontab file


crontab -u root /etc/crontab

5. Restart crontab


/etc/init.d/crond restart

6. Look at timer tasks


crontab -l

conclusion

Above is the site to you to solve the catalina. out continued to accumulate problems, I hope to help you, if you have any questions welcome to give me a message, this site will reply you in time!


Related articles: