大网数据广告活动
服务器运维问答

Logrotate Fails Without Error

· 52CE 我爱测

Ok, I made a boo-boo. I think Problem: Logrotate fails (or I incorrectly think its dead) and does not provide any error message to explain why: ● logrotate.service - Rotate log files Loaded: loaded (/lib/systemd/system/logrotate.…

问题原文

原帖链接 · Maestro223 · CC BY-SA 4.0

Ok, I made a boo-boo. I think

Problem: Logrotate fails (or I incorrectly think its dead) and does not provide any error message to explain why:

● 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.

I wanted to automatically restart logrotate using systemd because sometimes it would fail after a reboot. Therefore in my /usr/lib/systemd/system/logrotate.service file I added:

Restart=always

The above addition kill logrotate service. From there I decided to undo my dirty work and by deleting Restart=always and systemctl daemon-reload && systemctl start logrotate

No luck.

Then I decided to investigate the syslog and see if I could find any clues, using:
#grep "logrotate" /var/log/syslog. This yielded a clue:

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.

Note: all the times where you see "Succeeded" are from me manually trying to start logrotate.

I read in this post on server fault that this can problem can be caused by logrotate trying to access logs outside of the var/log/ directory. And I though that this may be my problem, however I can't find any indicator of a log outside /var/log, except for the syslog error above:

reiteration:

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

From I investigated clamd, but

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

Yields, nothing. Does anyone know why logrotate won't start?

已采纳解答

原帖链接 · AlexD · CC BY-SA 4.0

logrotate.service is supposed to be inactive. It doesn't run as a daemon but is triggered periodically by logrotate.timer, check systemctl status logrotate.timer.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-12-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。