nginx logs cut regular tasks logrotate

Profiles

/alidata/log/nginx/aipiaxi/*.log
{
  daily
  rotate 15
  missingok
  dateext
  compress
  notifempty
  sharedscripts
  postrotate
    if [ -f /var/run/nginx.pid ]; then
      kill -USR1 `cat /var/run/nginx.pid`
    be
  endscript
}

 

Finally, the script mean, let nginx logs begin a new log file.

 

Then add a scheduled task

crontab -e

0 4 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/nginx

4:00 daily log cutting

 

Log Format

 

nginx.conf

log_format main '[$time_iso8601] "$http_x_forwarded_for" "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" ';

# 使用 access_log /path/to/log main;

 

Guess you like

Origin www.cnblogs.com/aleafo/p/12315530.html