nginx_log

nginx 日志需要自己进程转储。

crontab 方式

1
2
3
4
mv access.log access.log.0
kill -USR1 `cat master.nginx.pid`
sleep 1
gzip access.log.0 # do something with access.log.0

Log Rotation

logrotate

在 /etc/logrotate.d/nginx 文件中添加:

1
2
3
4
5
6
7
8
9
10
11
12
/var/log/nginx/access/access.log { 
rotate 3
size=50G
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/sbin/nginx -s reload > /dev/null 2>&1
endscript
}