Package: logrotate
Version: 3.8.7-1+b1
Severity: normal
Tags: upstream patch
Dear Maintainer,
Sometimes files are not rotated during weekly logrotation, despite of
the fact that the last rotation was a week ago (within a few seconds).
This bugs seems to be introduced in Debian Jessie.
Debian Wheezy stored only the date of the last rotation in the
logrotate status file (/var/lib/logrotate/status) like:
"/var/log/syslog" 2016-5-29
The "hour", "minutes" and "seconds" were initialized as 0 when the
status file was read. This pins the timestamp of the last rotation
effectively at 12:00:00 AM.
Debian Jessie stores the full date and time:
"/var/log/syslog" 2016-5-29-6:25:4
and checks for weekly rotation if the last rotation was more than
(7 * 24 * 3600) seconds ago.
This check fails occasionally due to some jitter in the exact moment
that logrotate is started.
The patch below should fix this. (untested)
$ diff -u logrotate.c.original logrotate.c
--- logrotate.c.original2016-05-29 17:32:06.954792359 +0200
+++ logrotate.c 2016-05-29 17:39:56.674758835 +0200
@@ -856,12 +856,13 @@
1) the current weekday is before the weekday of the
last rotation
2) more then a week has passed since the last
- rotation */
+ rotation. Allow some jitter in the time - 60 seconds
+ should be sufficient and harmless. */
state->doRotate = ((now.tm_wday < state->lastRotated.tm_wday)
||
((mktime() -
mktime(>lastRotated)) >
- (7 * 24 * 3600)));
+ (7 * 24 * 3600 - 60)));
break;
case ROT_HOURLY:
state->doRotate = ((now.tm_hour != state->lastRotated.tm_hour) ||
Regards,
Kees Theunissen.
-- Package-specific info:
Contents of /etc/logrotate.d
total 32
-rw-r--r-- 1 root root 173 Apr 13 2015 apt
-rw-r--r-- 1 root root 79 Nov 8 2014 aptitude
-rw-r--r-- 1 root root 382 Mar 10 05:06 clamav-daemon
-rw-r--r-- 1 root root 409 Mar 10 05:06 clamav-freshclam
-rw-r--r-- 1 root root 139 Jan 15 2014 clamav-unofficial-sigs
-rw-r--r-- 1 root root 232 Apr 10 2015 dpkg
-rw-r--r-- 1 root root 140 Oct 16 2014 mimedefang
-rw-r--r-- 1 root root 515 Oct 2 2014 rsyslog
-- System Information:
Debian Release: 8.4
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages logrotate depends on:
ii base-passwd 3.5.37
ii cron [cron-daemon] 3.0pl1-127+deb8u1
ii libacl1 2.2.52-2
ii libc6 2.19-18+deb8u4
ii libpopt01.16-10
ii libselinux1 2.3-2
Versions of packages logrotate recommends:
ii bsd-mailx [mailx] 8.1.2-0.20141216cvs-2
logrotate suggests no packages.
-- no debconf information