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