Red Hat Bugzilla – Bug 139670
logrotate compress and postrotate order
Last modified: 2015-01-07 19:08:53 EST
Description of problem:
I have the following configured in /etc/logrotate.d/httpd:
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2>
/dev/null || true
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
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):
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
Do not use sharedscripts directive.
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.
I found that this good wish.
What do you think about implementing precomress/endscript so as to work with
sharedscripts directive ?