Bug 600333 - Logrotate rotates wtmp daily in spite of "monthly" specification
Summary: Logrotate rotates wtmp daily in spite of "monthly" specification
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: logrotate
Version: 5.5
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Jan Kaluža
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-04 13:27 UTC by David Tonhofer
Modified: 2010-06-16 12:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-06-16 12:19:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description David Tonhofer 2010-06-04 13:27:52 UTC
Description of problem:
=======================

"wtmp" shall be rotated monthly, as per the spec in /etc/logrotate.conf:

--------------------------------
# no packages own wtmp -- we'll rotate them here

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

SPECIAL in my setup: "logrotate" is started daily through an explicit call in root's crontab at 08:30.

OBSERVED: wtmp is rotated daily.

---------------------------------
[root@hikari ~]# stat /var/log/wtmp*

  File: `/var/log/wtmp'
  Size: 1536      	Blocks: 16         IO Block: 4096   regular file
Device: fd08h/64776d	Inode: 98326       Links: 1
Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (   22/    utmp)
Access: 2010-06-04 08:30:22.000000000 +0200
Modify: 2010-06-04 14:35:22.000000000 +0200
Change: 2010-06-04 14:35:22.000000000 +0200

  File: `/var/log/wtmp.1'
  Size: 3456      	Blocks: 16         IO Block: 4096   regular file
Device: fd08h/64776d	Inode: 98338       Links: 1
Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (   22/    utmp)
Access: 2010-06-03 08:30:50.000000000 +0200
Modify: 2010-06-04 02:53:12.000000000 +0200
Change: 2010-06-04 08:30:22.000000000 +0200 <--------

  File: `/var/log/wtmp.2'
  Size: 4608      	Blocks: 24         IO Block: 4096   regular file
Device: fd08h/64776d	Inode: 98328       Links: 1
Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (   22/    utmp)
Access: 2010-06-02 08:30:20.000000000 +0200
Modify: 2010-06-02 19:58:27.000000000 +0200
Change: 2010-06-04 08:30:22.000000000 +0200 <--------
---------------------------------

CHECKING LOGFILE:

---------------------------------
rotating pattern: /var/log/wtmp  forced from command line (10 rotations)
empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
considering log /var/log/wtmp
  log needs rotating
rotating log /var/log/wtmp, log->rotateCount is 10
renaming /var/log/wtmp.10 to /var/log/wtmp.11 (rotatecount 10, logstart 1, i 10), 
old log /var/log/wtmp.10 does not exist
renaming /var/log/wtmp.9 to /var/log/wtmp.10 (rotatecount 10, logstart 1, i 9), 
old log /var/log/wtmp.9 does not exist
renaming /var/log/wtmp.8 to /var/log/wtmp.9 (rotatecount 10, logstart 1, i 8), 
old log /var/log/wtmp.8 does not exist
renaming /var/log/wtmp.7 to /var/log/wtmp.8 (rotatecount 10, logstart 1, i 7), 
old log /var/log/wtmp.7 does not exist
renaming /var/log/wtmp.6 to /var/log/wtmp.7 (rotatecount 10, logstart 1, i 6), 
old log /var/log/wtmp.6 does not exist
renaming /var/log/wtmp.5 to /var/log/wtmp.6 (rotatecount 10, logstart 1, i 5), 
old log /var/log/wtmp.5 does not exist
renaming /var/log/wtmp.4 to /var/log/wtmp.5 (rotatecount 10, logstart 1, i 4), 
old log /var/log/wtmp.4 does not exist
renaming /var/log/wtmp.3 to /var/log/wtmp.4 (rotatecount 10, logstart 1, i 3), 
old log /var/log/wtmp.3 does not exist
renaming /var/log/wtmp.2 to /var/log/wtmp.3 (rotatecount 10, logstart 1, i 2), 
old log /var/log/wtmp.2 does not exist
renaming /var/log/wtmp.1 to /var/log/wtmp.2 (rotatecount 10, logstart 1, i 1), 
renaming /var/log/wtmp.0 to /var/log/wtmp.1 (rotatecount 10, logstart 1, i 0), 
old log /var/log/wtmp.0 does not exist
log /var/log/wtmp.11 doesn't exist -- won't try to dispose of it
renaming /var/log/wtmp to /var/log/wtmp.1
creating new log mode = 0664 uid = 0 gid = 22
---------------------------------

CHECKING /var/lib/logrotate.status 

---------------------------------
...
"/var/log/wtmp" 2010-6-4
...
---------------------------------

CHECKING MANPAGE:

---------------------------------
monthly ... Log files are rotated the first time logrotate is run in a month (this is normally on the first day of the month).
---------------------------------

Could it be that logrotate doesn't know that has run this month already?

Note that "logrotate" exits 1 because of a scripting error in a postrotate for the httpd log, wheres if it exists 0, monthly rotation is ok (?)

Will continue to observe.

Version-Release number of selected component (if applicable):
=============================================================

logrotate-3.7.4-9

How reproducible:
=================

Unsure. Works correctly on another machine running logrotate-3.7.4-9 on which logrotate exits with 0.

However, another machine running logrotate-3.7.4-9 on which logrotate exits with 0 exhibits the same problem.

Comment 1 David Tonhofer 2010-06-07 09:03:38 UTC
Tested a setup with only this in /etc/logrotate.conf:

--------------
weekly
rotate 4
create

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

then started logrotate manually:

--------------
/usr/sbin/logrotate -d -f /etc/logrotate.conf
--------------

Logrotate insits on rotating wtmp.

Comment 2 Daniel Novotny 2010-06-07 13:18:56 UTC
isn't that because of the "-f" switch, which forces rotation even when it's not necesarry?

Comment 3 David Tonhofer 2010-06-08 09:21:32 UTC
!!! Sweet baby Jesus !!!

You are most probably right.

That "-f" options must have creeped in there at some moment and I didn't notice it, being fixated on log output (but then again, shouldn't it say that the force option is on).

Okaayy trying without -f

Comment 4 Jan Kaluža 2010-06-16 12:19:51 UTC
I would say this is not a bug, because -f forces the rotation.

Comment 5 David Tonhofer 2010-06-16 12:38:44 UTC
Correct amundo.


Note You need to log in before you can comment on or make changes to this bug.