![logrotate 损坏但没有错误消息](https://linux22.com/image/754077/logrotate%20%E6%8D%9F%E5%9D%8F%E4%BD%86%E6%B2%A1%E6%9C%89%E9%94%99%E8%AF%AF%E6%B6%88%E6%81%AF.png)
似乎有很多常见问题,logrotate 没有按照其预期的方式运行,碰巧我也遇到了同样的情况。
-rw-r--r-- 1 root root 24G Jun 23 01:15 A10.log
-rw-r--r-- 1 root root 0 Jun 18 12:22 A110.log
-rw-r--r-- 1 root root 18G Jun 23 01:15 A11223.log
-rw-r--r-- 1 root root 0 Jun 22 00:00 A115.log
-rw-r--r-- 1 root root 18G Jun 23 01:15 A11.log
-rw-r--r-- 1 root root 1.1G Jun 23 01:15 A202.log
-rw-r--r-- 1 root root 2.5G Jun 23 01:15 A216.log
-rw-r--r-- 1 root root 496M Jun 23 01:15 A221.log
-rw-r--r-- 1 root root 18G Jun 23 01:15 A235.log
-rw-r--r-- 1 root root 515M Jun 23 01:15 A236.log
-rw-r--r-- 1 root root 17G Jun 23 01:15 A404.log
现在上面的输出显示了一些相当大的文件。Logrotate 应该每天运行,每天轮换文件,如果文件超过 1GB
/var/log/tomcat/A*.log {
daily
missingok
rotate 5
compress
maxsize 1G
notifempty
create 640 tomcat adm
sharedscripts
postrotate
/etc/init.d/tomcat stop > /dev/null
/etc/init.d/tomcat start > /dev/null
endscript
}
手动执行 logrotate 会给出以下输出
host:/usr/share/tomcat/logs# logrotate -f --verbose /etc/logrotate.d/rotateTomcat
reading config file /etc/logrotate.d/rotateTomcat
Handling 1 logs
rotating pattern: /var/log/tomcat/A*.log forced from command line (5 rotations)
empty log files are not rotated, log files >= 1073741824 are rotated earlier, old logs are removed
No logs found. Rotation not needed.
为什么它没有检测到该目录中任何大于 1GB 的日志文件?