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

Using shell script to cut tomcat and nginx logs in linux

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Online servers generally encounter a variety of log cuts. No similar detailed script article has been published before, so this time I will make up for the relevant content of the website. The following is a brief explanation of two log cuts, and the cutting of other service logs can also be realized in this way. Tomcat log catalina.out cutting mini script #! / bin/bash#cut tomcat catalina.outyesterday= `date + "% F"-d "- 1 days" `cd / usr/local/tomcat7.0.70/logcp catalina.out catalina.out.$yesterday echo > catalina.outexit

Can solve the problem of catalina.out log is too large. Scripts are just one way to do this, and you can also configure them manually or use other tools to implement them. In addition, if there are many tomcat projects, you can set the directory to a variable and repeat it in a loop.

Nginx access log slicing script (similar to other logs) #! / bin/bash#cut nginx access.log LOGS_PATH=/home/wwwroot/21yunwei/logsyesterday= `date + "% F"-d "- 1 days" `log ${LOGS_PATH} / 21yunwei.log ${LOGS_PATH} / 21yunwei painting ${yesterday} .logkill-USR1 $(cat / var/logs/nginx.pid)

Original address: https://www.linuxprobe.com/linux-shell-tomcat.html

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