nginx 使用 logrotate 回滚日志
作者: Bluedata | 可以转载,转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
网址: http://bluedata.org/2009/09/04/nginx-logrotate/
网址: http://bluedata.org/2009/09/04/nginx-logrotate/
vi /usr/local/nginx/conf/logrotate.conf
/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 www-data adm
sharedscripts
prerotate
sleep 59
endscript
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 www-data adm
sharedscripts
prerotate
sleep 59
endscript
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}
调试:
logrotate -d /usr/local/nginx/conf/logrotate.conf
执行:
logrotate -f /usr/local/nginx/conf/logrotate.conf
定期执行:
vi /etc/crontab
59 23 * * * root logrotate -f /usr/local/nginx/conf/logrotate.conf

















