1cd  /etc/logrotate.d
2vi /etc/logrotate.d/nginx
 1/home/wwwlogs/*.log {
 2    missingok
 3    dateext
 4    notifempty
 5    daily
 6    rotate 7
 7    sharedscripts
 8    postrotate
 9    if [ -f /usr/local/nginx/logs/nginx.pid ]; then
10        kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
11    fi
12    endscript
13}

:wq! 保存退出

1mkdir -p /usr/local/nginx/logs/nginx_logs/
2chmod +x /etc/logrotate.d/nginx #添加执行权限
3/usr/sbin/logrotate -vf /etc/logrotate.d/nginx
4crontab -e #添加以下代码
10 0 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/nginx #每天凌晨定时执行脚本