使用 Swatch 进行自动化日志监控
1. logrotate 的运行
通常, logrotate 由 /etc/cron.daily/logrotate 脚本调用,该脚本包含一个命令:
/usr/sbin/logrotate /etc/logrotate.conf
这并不意味着日志每天都会轮转,而是 logrotate 每天会根据其配置脚本检查每个日志文件,并相应地决定是否轮转该日志文件。
如果你希望 logrotate 运行的频率更低,可以将该脚本移动到 /etc/cron.weekly 甚至 /etc/cron.monthly (不过,除非出于某种奇怪的原因, logrotate 被配置为每月轮转每个文件,否则不建议使用 /etc/cron.monthly )。
常见的 logrotate 指令如下表所示:
| 指令 | 描述 |
| — | — |
| ifempty | notifempty | 默认情况下, logrotate 即使文件为空也会轮转。 notifempty 取消此行为; ifempty 恢复此行
超级会员免费看
订阅专栏 解锁全文
11

被折叠的 条评论
为什么被折叠?



