Logrotate Fails Without Error
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?
Solution 1:
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
.