You are not logged in.

#1 2013-10-23 22:38:49

medicineman
Member
From: Perry, Georgia
Registered: 2012-07-22
Posts: 7

[Solved] Logrotate not working

uname -a
Linux CLS 3.11.6-1-ARCH #1 SMP PREEMPT Fri Oct 18 23:22:36 CEST 2013 x86_64 GNU/Linux
logrotate --version
logrotate 3.8.7
cat /etc/logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# restrict maximum size of log files
size 10M

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# Logs are moved into directory for rotation
# olddir /var/log/archive

# Ignore pacman saved files
tabooext + .pacorig .pacnew .pacsave

# Arch packages drop log rotation information into this directory
include /etc/logrotate.d

/var/log/wtmp {
    monthly
    create 0664 root utmp
	minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}
cat /etc/logrotate.d/test

/var/log/test.log {
    missingok
    rotate 2
}
ls -l /var/log/test.log
-rw------- 1 root root 1104925 Oct 23 16:16 test.log
logrotate -fd /etc/logrotate.d/test

reading config file /etc/logrotate.d/test

Handling 1 logs

rotating pattern:  /var/log/test.log    forced from command line (2 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/test.log
  log needs rotating
rotating log /var/log/test.log, log->rotateCount is 2
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/test.log.2 to /var/log/test.log.3 (rotatecount 2, logstart 1, i 2),
renaming /var/log/test.log.1 to /var/log/test.log.2 (rotatecount 2, logstart 1, i 1),
renaming /var/log/test.log.0 to /var/log/test.log.1 (rotatecount 2, logstart 1, i 0),
renaming /var/log/test.log to /var/log/test.log.1
removing old log /var/log/test.log.3
error:  error opening /var/log/test.log.3:  No such file or directory
ls -l /var/log/test.log*
-rw------- 1 root root 1104925 Oct 23 16:16 test.log

As you can see, logrotate aborts and the file is not rotated.  I assumed the problem was with the missingok option so I tested this possiblity as shown below.


touch test.log.0 test.log.1 test.log.2 test.log.3

ls -l test.log*
-rw------- 1 root root 1104925 Oct 23 16:16 test.log
-rw------- 1 root root       0 Oct 23 17:37 test.log.0
-rw------- 1 root root       0 Oct 23 17:37 test.log.1
-rw------- 1 root root       0 Oct 23 17:37 test.log.2
-rw------- 1 root root       0 Oct 23 17:37 test.log.3

logrotate -fd /etc/logrotate.d/test
reading config file /etc/logrotate.d/test

Handling 1 logs

rotating pattern:  /var/log/test.log    forced from command line (2 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/test.log
  log needs rotating
rotating log /var/log/test.log, log->rotateCount is 2
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/test.log.2 to /var/log/test.log.3 (rotatecount 2, logstart 1, i 2),
renaming /var/log/test.log.1 to /var/log/test.log.2 (rotatecount 2, logstart 1, i 1),
renaming /var/log/test.log.0 to /var/log/test.log.1 (rotatecount 2, logstart 1, i 0),
renaming /var/log/test.log to /var/log/test.log.1
removing old log /var/log/test.log.3

ls -l test.log*
-rw------- 1 root root 1104925 Oct 23 16:16 test.log
-rw------- 1 root root       0 Oct 23 17:37 test.log.0
-rw------- 1 root root       0 Oct 23 17:37 test.log.1
-rw------- 1 root root       0 Oct 23 17:37 test.log.2
-rw------- 1 root root       0 Oct 23 17:37 test.log.3

No error but the file has not been rotated.
Anyone have ideas on what may be wrong.  The last time my logs were rotated was April.

Last edited by medicineman (2013-10-23 23:24:43)

Offline

#2 2013-10-23 22:46:51

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,989

Re: [Solved] Logrotate not working

Are you running logrotate as root?  Usually, it is run as a cron job with root permissions.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2013-10-23 22:52:59

medicineman
Member
From: Perry, Georgia
Registered: 2012-07-22
Posts: 7

Re: [Solved] Logrotate not working

I noticed last night that the logs have not been rotated.  For the moment, I am testing as root.  It normally runs as a cron job.

Offline

#4 2013-10-23 23:23:31

medicineman
Member
From: Perry, Georgia
Registered: 2012-07-22
Posts: 7

Re: [Solved] Logrotate not working

It seems my state file (/var/lib/logrotate.status) was corrupted.  I deleted this file and then did "logrotate -f /etc/logrotate.d/syslog-ng".  The state file was recreated and now everything is working again.  No idea how the file became corrupted, though.

Offline

Board footer

Powered by FluxBB