logrotate配置记录

对于一些比较频繁又没有太大意义的log,可以设定出更严格的切割策略

see https://blog.csdn.net/liuxiao723846/article/details/100120058

/var/log/nginx/*.log /var/log/tomcat/*log { # 可以指定多个路径
daily # 日志轮询周期,weekly,monthly,yearly
rotate 30 # 保存30天数据,超过的则删除
size +100M # 超过100M时分割,单位K,M,G,优先级高于daily
compress # 切割后压缩,也可以为nocompress
delaycompress # 切割时对上次的日志文件进行压缩
dateext # 日志文件切割时添加日期后缀
missingok # 如果没有日志文件也不报错
notifempty # 日志为空时不进行切换,默认为ifempty
create 640 nginx nginx # 使用该模式创建日志文件
sharedscripts # 所有的文件切割之后只执行一次下面脚本
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}

原文地址:https://www.cnblogs.com/yeyong/p/14897214.html