Bug 600333 - Logrotate rotates wtmp daily in spite of "monthly" specification
Logrotate rotates wtmp daily in spite of "monthly" specification
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: logrotate (Show other bugs)
5.5
All Linux
low Severity medium
: rc
: ---
Assigned To: Jan Kaluža
qe-baseos-daemons
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-04 09:27 EDT by David Tonhofer
Modified: 2010-06-16 08:38 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-06-16 08:19:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Tonhofer 2010-06-04 09:27:52 EDT
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 05:03:38 EDT
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 09:18:56 EDT
isn't that because of the "-f" switch, which forces rotation even when it's not necesarry?
Comment 3 David Tonhofer 2010-06-08 05:21:32 EDT
!!! 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 08:19:51 EDT
I would say this is not a bug, because -f forces the rotation.
Comment 5 David Tonhofer 2010-06-16 08:38:44 EDT
Correct amundo.

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