Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1510046

Summary: logrotate weekly rotation is inconsistent and unpredictable
Product: Red Hat Enterprise Linux 7 Reporter: Gilles Detillieux <grdetil>
Component: logrotateAssignee: Kamil Dudka <kdudka>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.4CC: kdudka
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-07 13:21:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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):
3.8.6-14

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 ***