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

Shell cutting log script

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

Share

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

Vi / etc/logrotate.d/nginx # Editing script

/ usr/local/nginx/logs/*.log / usr/local/nginx/logs/nginx_logs/*.log {

Missingok # ignores errors, such as the "log file cannot be found" error message.

Dateext # switched log files will be appended with a dash and a date in YYYYMMDD format. Without this configuration item, a decimal point and a numeric sequence number will be appended.

Notifempty # if the log file is empty, no cutting is performed.

Daily # cut logs on a daily basis. Available value month: monthly week: weekly year: yearly

Rotate 3 # keeps log records for the last 3 days

Sharedscripts # scripts that run only once for the entire log group

The commands specified in postrotate # will be executed

If [- f / usr/local/nginx/logs/nginx.pid]; then

Kill-USR1 `cat / usr/local/nginx/logs/ nginx.pid`

Fi

Endscript

}

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