Bug 139670 - logrotate compress and postrotate order
logrotate compress and postrotate order
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: logrotate (Show other bugs)
3.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Vrabec
Jay Turner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-17 07:06 EST by Dennixx
Modified: 2015-01-07 19:08 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-12-10 04:56:46 EST
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 Dennixx 2004-11-17 07:06:25 EST
Description of problem:
I have the following configured in /etc/logrotate.d/httpd:
----
/var/log/httpd/*log {
    compress
    monthly
    rotate 6
    missingok
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2>
/dev/null || true
        touch /var/log/httpd/APACHE_RESTART
    endscript
}
----

The 'touch' is there for debugging purposes.

The logrotate(8) manpage states:
----
The next section of the config files defined how to handle the log
file /var/log/messages. The log will go through five weekly rotations
before being  removed. After the log file has been rotated (but before
the old version of the log has been compressed), the command
/sbin/killall -HUP syslogd will be executed.
----

However, after some testing, I found that logrotate does things in the
following order:
1. Move the current access_log to access_log.1
2. Create a new empty access_log
3. gzip the access_log.1 into access_log.1.gz
4. run the postrotate scripts (HUP apache and touch the file)

I would like the compression to occur after the apache server has been
restarted (like the manpage suggests).


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

How reproducible:
Always

Steps to Reproduce:
1. setup a 'touch command' in the logrotate postrotate section
2. create a big logfile which takes some time to compress
3. run 'logrotate -f /etc/logrotate.conf' and see what happens.
    

Actual Results:  The files are being compressed before the postrotate
commands are run.

Expected Results:  The postrotate commands should run before the files
are compressed.

Additional info:
Comment 1 Peter Vrabec 2004-12-09 09:10:31 EST
Do not use sharedscripts directive.
Comment 2 Peter Vrabec 2004-12-10 04:56:46 EST
Sharedscripts directive will cause that the files are being compressed
before the postrotate.
It's pity that it is  not mentioned in man page. I'll try to fix it.
Comment 3 Sergey 2007-03-12 08:22:20 EDT
Hello. 

I found that this good wish. 
What do you think about implementing precomress/endscript so as to work with
sharedscripts directive ?

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