Bug 1510046 - logrotate weekly rotation is inconsistent and unpredictable
Summary: logrotate weekly rotation is inconsistent and unpredictable
Status: CLOSED DUPLICATE of bug 1465720
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: logrotate
Version: 7.4
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: qe-baseos-daemons
Depends On:
TreeView+ depends on / blocked
Reported: 2017-11-06 15:27 UTC by Gilles Detillieux
Modified: 2017-11-07 13:21 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2017-11-07 13:21:01 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Debian BTS 825776 None None None 2017-11-06 15:27:02 UTC

Description Gilles Detillieux 2017-11-06 15:27:03 UTC
Description of problem:
logrotate won't do weekly rotation if last week's rotation was even 1 second later than this week's rotation. This is nearly impossible to do consistently, even if running logrotate directly from a crontab entry, and certainly impossible when run from /etc/cron.daily/logrotate as it is by default. The result is that weekly rotations which should occur on Sunday often don't happen until Monday morning. A hook in logrotate seems to reset things so that after a Monday rotation, the next one occurs on Sunday (weekday comparison in addition to time comparison).

Version-Release number of selected component (if applicable):

How reproducible:
Happens quite frequently.

Steps to Reproduce:
1. Wait for logrotate to run Sunday morning, then check later that day or the next.
2. ls -ltr /var/log/messages*
3. Look at the dates of the rotated log files.
4. Note that they're not always 7 days apart - some are on Monday rather than Sunday

Actual results:
-rw-------. 1 root root 20645073 Oct 16 04:18 /var/log/messages-20171016
-rw-------. 1 root root 17065169 Oct 22 04:17 /var/log/messages-20171022
-rw-------. 1 root root 15279183 Oct 29 07:45 /var/log/messages-20171029
-rw-------. 1 root root 14792166 Nov  6 04:44 /var/log/messages-20171106
-rw-------. 1 root root   325138 Nov  6 08:52 /var/log/messages

Expected results:
-rw-------. 1 root root 20645073 Oct 15 04:18 /var/log/messages-20171015
-rw-------. 1 root root 17065169 Oct 22 04:17 /var/log/messages-20171022
-rw-------. 1 root root 15279183 Oct 29 07:45 /var/log/messages-20171029
-rw-------. 1 root root 14792166 Nov  5 04:44 /var/log/messages-20171105
-rw-------. 1 root root   325138 Nov  6 08:52 /var/log/messages

Additional info:
This bug should be fixed in logrotate 3.12.0 or later. See https://github.com/logrotate/logrotate/releases/tag/3.12.0 for changelog (item "weekly rotations are now predictable and configurable (#93)). Updating to this version, or the latest upstream version, should fix this bug.

Alternatively, the test in logrotate.c should be patched to be less obsessive about what constitutes a week. The Debian bug report for this has a patch to allow 60 seconds of jitter, which might work if you only run logrotate at a consistent time from a crontab entry, but won't be sufficient for the often several hours of variability when running from cron.daily. Rather than 60 s, the jitter should be more like 6 hours (6 * 3600). See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825776 for that attempted solution. (The follow-up discussion recommended the upstream fix instead.)

Comment 2 Kamil Dudka 2017-11-06 16:07:19 UTC
Indeed.  We are going to fix this bug in RHEL-7.5.  Let me check if we can disclose the corresponding bug (bug #1465720) for public to avoid reporting duplicates like this.

Comment 3 Kamil Dudka 2017-11-07 13:21:01 UTC
Done.  Please comment on bug #1465720 if you have any follow-up on this...

*** This bug has been marked as a duplicate of bug 1465720 ***

Note You need to log in before you can comment on or make changes to this bug.