Vi/etc/logrotate.d/nginx #编辑脚本
/usr/local/nginx/logs/*.log/usr/local/nginx/logs/nginx_logs/*.log{
Missingok # ignores errors, such as "log file cannot be found" error message.
Dateext # The log file after the switch is appended with the date of the last dash and YYYYMMDD format, and no such configuration item appends a decimal point plus a numeric sequence number
Notifempty # If the log file is empty, no cuts are performed.
Daily # cut logs by day. Available values month: Monthly week: Weekly year: Yearly
Rotate 3 # keep log records for the last 3 days
Sharedscripts # scripts that run only once for the entire log group
Postrotate # The command specified inside will be executed
if [-f/usr/local/nginx/logs/nginx.pid]; Then
KILL-USR1 ' Cat/usr/local/nginx/logs/nginx.pid '
Fi
Endscript
}
This article is from the "Dr Small White" blog, please be sure to keep this source http://1213503.blog.51cto.com/1203503/1927448
Shell Cut Log Script