在 /etc/logrotate.d/ 下创建文件
/var/log/nginx/*log {
create 0644 ec2-user adm
daily
dateext
dateformat -%Y%m%d
rotate 90
missingok
notifempty
compress
sharedscripts
postrotate
day=$(date +%Y%m%d)
/bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
endscript
}
然后执行下面代码测试一下
sudo logrotate -f /etc/logrotate.d/nginx