Bug 139670 - logrotate compress and postrotate order
Summary: logrotate compress and postrotate order
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: logrotate
Version: 3.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Peter Vrabec
QA Contact: Jay Turner
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-11-17 12:06 UTC by Dennixx
Modified: 2015-01-08 00:08 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-12-10 09:56:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Dennixx 2004-11-17 12:06:25 UTC
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 14:10:31 UTC
Do not use sharedscripts directive.


Comment 2 Peter Vrabec 2004-12-10 09:56:46 UTC
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 12:22:20 UTC
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.