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 /etc/logrotate.d/cron 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 %s\n", stateFilename); fclose(f); 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. Cheers, Seth
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 runs.
The fix can be found in logrotate 3.0 or greater, in the RawHide tree and releases of Red Hat Linux > 5.2.
auter-0.11-5.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-428fe8d2cd