logrotate systemd timer should run hourly rather than daily

Bug #2037022 reported by Todd Jacobsen
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
logrotate (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Logrotate supports "hourly rotation, however the Ubuntu logrotate systemd Timer runs "daily" - so "hourly" logrotate jobs are still only run daily.

Updating /etc/systemd/system/timers.target.wants/logrotate.timer:
...
[Timer]
OnCalendar=hourly
...

should allow "logrotate hourly" to work as expected.

See related comment at https://github.com/logrotate/logrotate/issues/249#issuecomment-485829363
"The tricky part is that one needs to change the default cron hook
(or systemd timer) to make hourly actually work as expected."

Thanks!

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: logrotate 3.21.0-1
ProcVersionSignature: Ubuntu 6.2.0-32.32-generic 6.2.16
Uname: Linux 6.2.0-32-generic x86_64
ApportVersion: 2.26.1-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Thu Sep 21 22:11:04 2023
ProcEnviron:
 LANG=en_US.UTF-8
 PATH=(custom, no user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: logrotate
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Todd Jacobsen (yolabingo) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in logrotate (Ubuntu):
status: New → Confirmed
Revision history for this message
ebob9 (ebob9) wrote :

I am hitting this issue as well - I've been able to work around it by running a script post startup which uses sed to replace the `Daily` lines in the logrotate.timer file with hourly, and reload the systemd daemon config.

#!/bin/bash
sed -i "/Description=Daily rotation of log files/c\Description=Hourly rotation of log files" /lib/systemd/system/logrotate.timer
sed -i "/OnCalendar=daily/c\OnCalendar=hourly" /lib/systemd/system/logrotate.timer
systemctl daemon-reload; systemctl stop logrotate.timer; systemctl start logrotate.timer

This is a crude workaround, but I assume the actual fix should be to modify the same items in the distro logrotate.timer file.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.