Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of regularly deleting logs by tomcat

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report