Bug 98331

Summary: logrotate removes file as it is archived
Product: [Retired] Red Hat Linux Reporter: John Wingenbach <redhat>
Component: logrotateAssignee: Elliot Lee <sopwith>
Status: CLOSED NOTABUG QA Contact: Jay Turner <jturner>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: srevivo
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-07-09 18:53:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Wingenbach 2003-07-01 10:20:58 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.3.1) Gecko/20030425

Description of problem:
Upon execution, logrotate is removing the log file it just archived.  It should
be keeping the standard 4.  However, it is not.

logrotate -d -f httpd
reading config file httpd
reading config info for /var/log/httpd/*log

Handling 1 logs

rotating pattern: /var/log/httpd/*log  forced from command line (no old logs
will be kept)
empty log files are rotated, old logs are removed
considering log /var/log/httpd/access_log
  log needs rotating
considering log /var/log/httpd/error_log
  log needs rotating
considering log /var/log/httpd/ssl_access_log
  log needs rotating
considering log /var/log/httpd/ssl_error_log
  log needs rotating
considering log /var/log/httpd/ssl_request_log
  log needs rotating
rotating log /var/log/httpd/access_log
renaming /var/log/httpd/access_log.0 to /var/log/httpd/access_log.1 (rotatecount
1, logstart 0, i 0),
renaming /var/log/httpd/access_log to /var/log/httpd/access_log.0
disposeName will be /var/log/httpd/access_log.0
removing old log /var/log/httpd/access_log.0
rotating log /var/log/httpd/error_log
renaming /var/log/httpd/error_log.0 to /var/log/httpd/error_log.1 (rotatecount
1, logstart 0, i 0),
renaming /var/log/httpd/error_log to /var/log/httpd/error_log.0
disposeName will be /var/log/httpd/error_log.0
removing old log /var/log/httpd/error_log.0
rotating log /var/log/httpd/ssl_access_log
renaming /var/log/httpd/ssl_access_log.0 to /var/log/httpd/ssl_access_log.1
(rotatecount 1, logstart 0, i 0),
renaming /var/log/httpd/ssl_access_log to /var/log/httpd/ssl_access_log.0
disposeName will be /var/log/httpd/ssl_access_log.0
removing old log /var/log/httpd/ssl_access_log.0
rotating log /var/log/httpd/ssl_error_log
renaming /var/log/httpd/ssl_error_log.0 to /var/log/httpd/ssl_error_log.1
(rotatecount 1, logstart 0, i 0),
renaming /var/log/httpd/ssl_error_log to /var/log/httpd/ssl_error_log.0
disposeName will be /var/log/httpd/ssl_error_log.0
removing old log /var/log/httpd/ssl_error_log.0
rotating log /var/log/httpd/ssl_request_log
renaming /var/log/httpd/ssl_request_log.0 to /var/log/httpd/ssl_request_log.1
(rotatecount 1, logstart 0, i 0),
renaming /var/log/httpd/ssl_request_log to /var/log/httpd/ssl_request_log.0
disposeName will be /var/log/httpd/ssl_request_log.0
removing old log /var/log/httpd/ssl_request_log.0
running shared postrotate script
running script with arg /var/log/httpd/*log : "
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
"


Note that the disposeName is the name of the archive just created.  The
logrotate configs are:
httpd:
/var/log/httpd/*log {
    start 0
    daily
    missingok
    ifempty
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

logrotate.conf:
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

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

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

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

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}
# system-specific logs may be also be configured here.




Version-Release number of selected component (if applicable):
logrotate-3.6.8-1

How reproducible:
Always

Steps to Reproduce:
1.use the configurations listed in the bug report
2. execute logrotate -d -f httpd
3.
    

Actual Results:  logrotate rotated the logs but deleted the newly created
archived logs.

Expected Results:  logrotate should have kept 4 archives.

Additional info:

Comment 1 Elliot Lee 2003-07-09 18:53:08 UTC
You can't run logrotate like that on a single incomplete config file. You'd need to do 
'logrotate -f /etc/logrotate.conf' so it gets all the settings (such as the 'rotate' line) and 
rotates all logfiles.