Logrotate 失败且无错误

Logrotate 失败且无错误

好吧,我犯了一个错误。我认为

问题: Logrotate 失败(或者我错误地认为它已经死机)并且没有提供任何错误消息来解释原因:

● logrotate.service - Rotate log files
   Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset: enabled)
   Active: inactive (dead) since Fri 2021-12-31 13:05:25 CST; 42min ago
     Docs: man:logrotate(8)
           man:logrotate.conf(5)
  Process: 27844 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=0/SUCCESS)
 Main PID: 27844 (code=exited, status=0/SUCCESS)

Dec 31 13:05:25 server1.example.com systemd[1]: Starting Rotate log files...
Dec 31 13:05:25 server1.example.com systemd[1]: logrotate.service: Succeeded.
Dec 31 13:05:25 server1.example.com systemd[1]: Started Rotate log files.

我想使用 systemd 自动重启 logrotate,因为有时它在重启后会失败。因此,/usr/lib/systemd/system/logrotate.service我在文件中添加了:

Restart=always

上述添加会终止 logrotate 服务。从那里我决定撤销我的肮脏工作,并通过删除Restart=alwayssystemctl daemon-reload && systemctl start logrotate

没有运气。

然后我决定调查系统日志,看看能否找到任何线索,使用:
#grep "logrotate" /var/log/syslog。这产生了一条线索:

Dec 31 00:00:03 server1 systemd[1]: logrotate.service: Succeeded.
Dec 31 00:36:16 server1 clamd[3544]: Fri Dec 31 00:36:16 2021 -> ^File path check failure on: /var/tmp/systemd-private-2f8e6be5a16040adb29706b9e31ae841-logrotate.service-DbrlAK
Dec 31 00:37:31 server1 systemd[1]: logrotate.service: Succeeded.
Dec 31 12:51:17 server1 systemd[1]: logrotate.service: Succeeded.
Dec 31 13:00:58 server1 systemd[1]: logrotate.service: Succeeded.
Dec 31 13:05:25 server1 systemd[1]: logrotate.service: Succeeded.

注意:所有您看到“成功”的情况都是我手动尝试启动 logrotate 时出现的。

我读这篇关于服务器故障的帖子这个问题可能是由于 logrotate 尝试访问目录之外的日志而导致的。我以为这可能是我的问题,但是除了上面的 syslog 错误之外,var/log/我找不到任何外部日志的指示:/var/log

重申:

Dec 31 00:36:16 server1 clamd[3544]: Fri Dec 31 00:36:16 2021 -> ^File path check failure on: /var/tmp/systemd-private-2f8e6be5a16040adb29706b9e31ae841-logrotate.service-DbrlAK

从我调查了clamd,但是

#grep "log" /etc/clamav/clamd.conf 
LogSyslog false
LogFile /var/log/clamav/clamav.log

没有任何结果。有人知道为什么 logrotate 无法启动吗?

答案1

logrotate.service应该处于非活动状态。它不作为守护进程运行,而是由 定期触发logrotate.timer,请检查systemctl status logrotate.timer

相关内容