In the /etc/logrotate.d/apache file, the postrotate sections blindly try to
kill -HUP httpd:
/usr/bin/killall -HUP httpd 2> /dev/null || true
The "|| true" part prevents the logrotate program from reporting extraneous
errors if httpd isn't enabled, and indeed, this is an improvement over Red
Hat Linux 6.1, which simply had:
/usr/bin/killall -HUP httpd 2> /dev/null
But this construct also discards any legitimate errors from the killall
-HUP attempt. If httpd *is* running, and the killall -HUP fails, then an
error *should* be reported.
A cleaner way to code the postrotate section is to say:
if /sbin/chkconfig httpd; then
/usr/bin/killall -HUP httpd
This will Do The Right Thing in all cases.
Created attachment 222 [details]
patch for /etc/logrotate.d/apache
Thanks, this will be fixed in the package being worked on for 2.0. The relevant
snippet is now:
if /sbin/chkconfig httpd ; then
/usr/bin/killall -HUP /usr/sbin/httpd
Could also add "notifempty". If the apache isn't running then
the logfiles will stay empty and no logrotate is attempted.
Similar for the other logrotate specs. Some of them already
has "notifempty", though.
That's not necessarily true, though. If apache had just been shut down that
day, then the log files would most likely *not* be empty. But attempting to
"killall -HUP httpd" would still fail.
IMO, using chkconfig is still the best test whether one should expect to find
the daemon for that particular service running.
Also having a "notifempty" case would probably make sense on general principle,