Bug 143

Summary: Problem with reading state file in logrotate coding bug in logrotate
Product: [Retired] Red Hat Linux Reporter: seth
Component: logrotateAssignee: Cristian Gafton <gafton>
Severity: low Docs Contact:
Priority: low    
Version: 5.2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-03-18 15:32:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description seth 1998-11-20 07:03:01 UTC
I ran two logrotates simultaneously as a cron job.

(in abbreviated form)

26 02 * * * logrotate file1
26 02 * * * logrotate file2

(I realize that the idea is to run logrotate once
and then use includes to pull in various files...
but since when did "stupid users" (tm) follow the
intentions of software designers. )

Anyway, I got this error message in the mail:

Subject: Cron <root@pc126> /usr/sbin/logrotate

error: bad line 134538360 in state file

Question:  Was this because of a possible file locking
problem with both logrotates trying to read the status
file at the same time?

Bug report:  The relevant piece of the source code
starts on line 687 in the function readState()

  if (sscanf(buf, "%s %d-%d-%d\n", buf2, &year, &month,
&day) != 4) {
            message(MESS_ERROR, "bad line %d in state file
            return 1;

The "error" report that I got is not so helpful, because
there is a value missing in the message() statement.

Shouldn't it be:
 message(MESS_ERROR, "bad line %d in state file %s\n",
                    line, stateFilename);

But I am still curious to understand why the problem
appeared at all.  In fact, the log that was supposed
to be rotated simply disappeared.  Not very nice behavior.
I can provide more specific details on request.


Comment 1 Preston Brown 1999-03-18 15:30:59 UTC
We have fixed the problem with the line number reported.  Yes there is
a race condition here, which you triggered by starting two logrotates
at the exact same time.  If you want to run one logrotate followed by
another, I suggest that you leave at least a minute in between the

Comment 2 Preston Brown 1999-03-18 15:32:59 UTC
The fix can be found in logrotate 3.0 or greater, in the RawHide tree
and releases of Red Hat Linux > 5.2.

Comment 3 Fedora Update System 2018-05-02 13:03:22 UTC
auter-0.11-5.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-428fe8d2cd