Catalina. out in Tomcat continues to accumulate the problem. Solution: tomcatcatalina. out

Source: Internet
Author: User

Catalina. out in Tomcat continues to accumulate the problem. Solution: tomcatcatalina. out

This method does not require you to modify the Tomcat configuration for beta testing. It is available.

1. Add the file clear_log.sh In the tomcat bin directory.

The content 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 the sh file to the operation permission

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

3. Add the/etc/crontab file (timer) at the bottom of the document (execute the script at 00:01 every day ):

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

4. Load the crontab file

Crontab-u root/etc/crontab

5. Restart crontab

/Etc/init. d/crond restart

6. View scheduled tasks

Crontab-l

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.