版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011192409/article/details/82853905
1、脚本如下:
/gdsfapps/flgw/logs/nginx/*.log{
missingok
dateext
notifempty
daily
rotate 7
sharedscripts
postrotate
if [ -f /usr/local/nginx/logs/nginx.pid ]; then
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
fi
endscript
}
2、脚本说明:
/gdsfapps/flgw/logs/nginx/这个是nginx日志所在目录。/usr/local/nginx/logs/nginx.pid。这个是pid文件所在的绝对路径位置,其他配置项这里就不做说明了。
然后用crontab -e命令。将0 0 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/nginx写入到定时任务
切分之后就可以在日志目录看到如下所示的效果图: