Bug 139670

Summary: logrotate compress and postrotate order
Product: Red Hat Enterprise Linux 3 Reporter: Dennixx <voetelink>
Component: logrotateAssignee: Peter Vrabec <pvrabec>
Status: CLOSED NOTABUG QA Contact: Jay Turner <jturner>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: a_s_y, 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: 2004-12-10 09:56:46 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 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 ?