Answers:
在向Unix守护程序发送挂断信号(SIGHUP)时,它们刷新和/或旋转日志文件已成为一种非正式的半标准。Nginx并不遵循该约定,但是它以USR1相同的方式响应信号,如Nginx网站上标题为Log Rotation所示。
因此,您可以尝试类似
kill -s USR1 `pidof nginx`
              logrotating nginx日志:
# nginx SIGUSR1: Re-opens the log files.
/opt/nginx/logs/access.log {
  missingok
  notifempty
  delaycompress
  sharedscripts
  postrotate
    test ! -f /opt/nginx/logs/nginx.pid || kill -USR1 `cat /opt/nginx/logs/nginx.pid`
 endscript 
}
/opt/nginx/logs/error.log {
  missingok
  notifempty
  delaycompress
  sharedscripts
  postrotate  
    test ! -f /opt/nginx/logs/nginx.pid || kill -USR1 `cat /opt/nginx/logs/nginx.pid`
  endscript
}
logrotating滑轨生产日志:
/home/app_user/apps/railsapp/log/production.log {
  missingok
  notifempty
  delaycompress
  sharedscripts
  postrotate
    test ! -f /opt/nginx/logs/nginx.pid || kill -USR1 `cat /opt/nginx/logs/nginx.pid`
  endscript
}
              /etc/logrotate.d/nginx。它将生效。
                    如果您使用logrotate,请将以下内容(具有正确的位置)添加到logrotate.conf的nginx部分中:
postrotate
  kill -s USR1 `cat /location/of/nginx.pid`
endscript