vi nginx_log
/usr/local/nginx/logs/*.log {
daily
dateext
compress
rotate 30
sharedscripts
postrotate
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
endscript
}
這是切割保留30天
測試
/usr/sbin/logrotate -f /root/nginx_log
按時切割
定時
crontab -e
* 2 * * * /usr/sbin/logrotate -f /root/nginx_log