You are not logged in.

#1 2020-08-03 14:37:54

dwheeler
Member
Registered: 2010-11-12
Posts: 21

[SOLVED] Logrotate 3.17 State File Locks

On one of my systems, I have apache and syslog-ng installed. Each one has a logrotate configuration (in /etc/logrotate.d). I have set the apache logs to be rotated once a week, with the syslog-ng logs being rotated daily. Apart from occasional issues during switches to/from daylight savings, this configuration has worked without issue for years. Last night, the 2nd of the jobs to start (syslog-ng) started before the first job was completed, and resulted in this logged error:

error: state file /var/lib/logrotate.status is already locked
logrotate does not support parallel execution on the same set of logfiles.

In looking into this, I see a new option is available in the logrotate man page:

-s, --state statefile
      Tells logrotate to use an alternate state file.  This is useful if logrotate is being run as a different user for various sets of log files.  To prevent parallel execution logrotate by default acquires a lock  on  the
      state file, if it cannot be acquired logrotate will exit with value 3.  The default state file is /var/lib/logrotate.status.

I'm going to try using a separate state file for each logrotate configuration to see if this alleviates the issues, though I will not know until next Monday if it's completely successful. I will post my results then, but in the meantime, I wanted to point this out to anyone else who is seeing this same error.

Last edited by dwheeler (2020-08-10 17:59:47)

Offline

#2 2020-08-10 17:59:34

dwheeler
Member
Registered: 2010-11-12
Posts: 21

Re: [SOLVED] Logrotate 3.17 State File Locks

The workaround of having separate state files worked.
I'm marking this as solved.

Offline

Board footer

Powered by FluxBB