Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of regularly deleting logs by tomcat

Shulou Source: shulou.com Published: 2022-06-02 02:06:10 10月31日 Update

This article is to share with you about tomcat's method of regularly deleting logs. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Specific methods:

I. create a script

Vim / root/project/tomcat_logs_task/auto-del-15-days-ago-log.sh

# / bin/bash# periodically delete tomcat periodically delete split logs 15 days ago # Log path apache_tomcat_api_8079=/root/app/apache-tomcat-job36-api-8079/logsapache_tomcat_api_8080=/root/app/apache-tomcat-job36-api-8080/logs apache_tomcat_admin_8081=/root/app/apache-tomcat-job36-admin-8081/logsapache_tomcat_admin_8082=/root/app/apache-tomcat-job36-admin-8082/ Logs find $apache_tomcat_api_8079-mtime + 15-name "localhost_access_log.*"-exec rm-rf {}\ Find $apache_tomcat_api_8079-mtime + 15-name "localhost.*"-exec rm-rf {}\; find $apache_tomcat_api_8079-mtime + 15-name "manager.*"-exec rm-rf {}\; find $apache_tomcat_api_8079-mtime + 15-name "catalina.*"-exec rm-rf {}; find $apache_tomcat_api_8079-mtime + 15-name "host-manager.*"-exec rm-rf {}\ Find $apache_tomcat_api_8080-mtime + 15-name "localhost_access_log.*"-exec rm-rf {}\; find $apache_tomcat_api_8080-mtime + 15-name "localhost.*"-exec rm-rf {}\; find $apache_tomcat_api_8080-mtime + 15-name "manager.*"-exec rm-rf {}; find $apache_tomcat_api_8080-mtime + 15-name "catalina.*"-exec rm-rf {}\ Find $apache_tomcat_api_8080-mtime + 15-name "host-manager.*"-exec rm-rf {}\; find $apache_tomcat_admin_8081-mtime + 15-name "localhost_access_log.*"-exec rm-rf {}\; find $apache_tomcat_admin_8081-mtime + 15-name "localhost.*"-exec rm-rf {}; find $apache_tomcat_admin_8081-mtime + 15-name "manager.*"-exec rm-rf {}\ Find $apache_tomcat_admin_8081-mtime + 15-name "catalina.*"-exec rm-rf {}\; find $apache_tomcat_admin_8081-mtime + 15-name "host-manager.*"-exec rm-rf {}\; find $apache_tomcat_admin_8082-mtime + 15-name "localhost_access_log.*"-exec rm-rf {}; find $apache_tomcat_admin_8082-mtime + 15-name "localhost.*"-exec rm-rf {}\ Find $apache_tomcat_admin_8082-mtime + 15-name "manager.*"-exec rm-rf {}\; find $apache_tomcat_admin_8082-mtime + 15-name "catalina.*"-exec rm-rf {}; find $apache_tomcat_admin_8082-mtime + 15-name "host-manager.*"-exec rm-rf {}\

Second, formulate an implementation plan

Vim / root/project/tomcat_logs_task/auto-del-15-days-ago-log.cron0 1 *. / etc/profile;/bin/sh / root/project/tomcat_logs_task/auto-del-15-days-ago-log.sh

Third, join the task

Crontab-e 0 1 *. / etc/profile;/bin/sh / root/project/tomcat_logs_task/auto-del-15-days-ago-log.sh Thank you for reading! The method of regularly deleting logs in tomcat is shared here. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Tags: Logs methods content more good practical tasks articles read knowledge articles scripts paths references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL macOS Microsoft MariaDB