JumpZero
Posts: 1156
Joined: Thu Mar 28, 2013 7:35 pm
Location: 127.0.0.1

buster: logrotate is now driven by systemd

Mon Oct 07, 2019 2:32 pm

Hello,
On September 9th I updated my home server running on a Pi2 from Stretch to Buster, except some minor things everything went ok.
Today I noticed that the daily log rotation time has changed from 06:25 to 00:00.
Digging more deeply I found that logrotate is now launched by systemd.

Code: Select all

root@NewBox:/ # systemctl status logrotate.service 
● logrotate.service - Rotate log files
   Loaded: loaded (/lib/systemd/system/logrotate.service; static; vendor preset: enabled)
   Active: inactive (dead) since Mon 2019-10-07 00:00:03 CEST; 16h ago
     Docs: man:logrotate(8)
           man:logrotate.conf(5)
  Process: 13978 ExecStart=/usr/sbin/logrotate /etc/logrotate.conf (code=exited, status=0/SUCCESS)
 Main PID: 13978 (code=exited, status=0/SUCCESS)

Oct 07 00:00:01 NewBox systemd[1]: Starting Rotate log files...
Oct 07 00:00:03 NewBox logrotate[13978]: error: Compressing program wrote following message to stder
Oct 07 00:00:03 NewBox logrotate[13978]: gzip: stdin: file size changed while zipping
Oct 07 00:00:03 NewBox systemd[1]: logrotate.service: Succeeded.
Oct 07 00:00:03 NewBox systemd[1]: Started Rotate log files.
root@NewBox:/ # systemctl status logrotate.timer 
● logrotate.timer - Daily rotation of log files
   Loaded: loaded (/lib/systemd/system/logrotate.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Tue 2019-09-10 17:36:03 CEST; 3 weeks 5 days ago
  Trigger: Tue 2019-10-08 00:00:00 CEST; 7h left
     Docs: man:logrotate(8)
           man:logrotate.conf(5)
So there is a systemd logrotate.timer launching logrotate.service everyday at 00:00.
Before logrotate was launched by cron, /etc/cron.daily/logrotate
There is now a comment in this script saying “skip in favour of systemd timer”
This isn’t a big issue but it’s not well documented and in this case why have changed the time?
Also the logrotate man page still says it’s launched by cron.
I log some sensors values, mainly temperatures, in /var/log/mysensors and use logrotate to rotate the logs. I create graphs from the logs. I now have some weird graphs because supposed to start at 06:25 and actually start at 00:00.
Again this is a minor issue and can easily change it but I’m just surprised: why have changed the log rotation time?
I believe it’s more Debian related than Raspbian but anyway I didn’t found many comment about this on the web.

davef
Posts: 64
Joined: Wed Feb 20, 2013 8:39 pm
Location: Christchurch, NZ

Re: buster: logrotate is now driven by systemd

Sun Nov 17, 2019 8:19 pm

JumpZero,

Thanks for posting this. I was doing another stuff at 00:00 and after the logrotate the system either unsuccessfully didn't make a WiFi connection or stopped doing my main cron job.

Tried to find where one could change the time unsuccessfully, so followed the suggestion of moving /etc/cron.daily/logrotate to another directory and putting another job in cron at a different time pointing to that new directory.

Cheers,
Dave

jj_0
Posts: 117
Joined: Wed Jul 11, 2012 7:07 am

Re: buster: logrotate is now driven by systemd

Sun Nov 17, 2019 9:19 pm

davef wrote:
Sun Nov 17, 2019 8:19 pm
JumpZero,

Thanks for posting this. I was doing another stuff at 00:00 and after the logrotate the system either unsuccessfully didn't make a WiFi connection or stopped doing my main cron job.

Tried to find where one could change the time unsuccessfully, so followed the suggestion of moving /etc/cron.daily/logrotate to another directory and putting another job in cron at a different time pointing to that new directory.

Cheers,
Dave
See https://wiki.archlinux.org/index.php/Systemd/Timers, edit the logrotate.timer file according to the Realtime section

Return to “Raspberry Pi OS”