Nginx日志切割
Nginx日志切割使用logrotate的配置
# cat /etc/logrotate.d/nginx /data/nginx/logs/*log { daily copytruncate rotate 30 missingok notifempty compress sharedscripts postrotate endscript }
保存一下,第二天就可以看看你的日志是否自动切割压缩了。
手动测试是否能运行
logrotate -d /etc/logrotate.d/nginx
查看一下配置之后的效果
# ll /data/nginx/logs/ total 613992 -rw-r--r-- 1 root root 77070771 Dec 10 17:36 access.log -rw-r--r-- 1 root root 55349148 Dec 8 03:24 access.log-20211208.gz
注:日志切割尤为重要,在Nginx配置之后,日志的切割和轮替应该是必须要配置的。
本文来自博客园,作者:kuzane,转载请注明原文链接:https://www.cnblogs.com/kuzane/articles/15673018.html

浙公网安备 33010602011771号