Comment 0 for bug 1649168

Revision history for this message
Doug Smythies (dsmythies) wrote : weekly log roation is often a day late

Over the last few Ubuntu releases, the status file the logrotate generates and uses has been adding more and more detailed time stamp information.

In 12.04 it seems to only keep information to the day.
In 14.04 it seems to only keep information to the hour.
In 16.04 it seems to keep information to the second.

However, the weekly section of the logrotate program calculates the time since the last rotation to the second with absolutely no jitter margin, and therefore as often as every other week, weekly logs that should rotate on Sunday do not rotate until Monday. I have 43 weeks of weekly rotation data, where on 17 of those weeks the rotation was on Monday and not Sunday. Note that the week after Monday rotation it will always rotate on Sunday due to "the current weekday is before the weekday of the last rotation" condition.

Code segment:

        case ROT_WEEKLY:
            /* rotate if:
               1) the current weekday is before the weekday of the
               last rotation
               2) more then a week has passed since the last
               rotation */
            state->doRotate = ((now.tm_wday < state->lastRotated.tm_wday)
                               ||
                               ((mktime(&now) -
                                 mktime(&state->lastRotated)) >
                                (7 * 24 * 3600)));

There is an upstream bug report at: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825776
which I will attempt to link in. It suggests introducing a 60 jitter allowance. I would make it more myself.

I first noticed this issue during 16.04 development in 2016.02 (Feb).
See also: https://ubuntuforums.org/showthread.php?t=2320149

Do not ask me to run apport collect for this bug report, because it is not needed, and it never works for me anyhow.