Bug 11167 - a better way to code /etc/logrotate.d/apache
Summary: a better way to code /etc/logrotate.d/apache
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: apache   
(Show other bugs)
Version: 6.2
Hardware: All Linux
Target Milestone: ---
Assignee: Nalin Dahyabhai
QA Contact:
Keywords: FutureFeature
Depends On:
TreeView+ depends on / blocked
Reported: 2000-05-02 02:54 UTC by James Ralston
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-05-02 18:18:36 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch for /etc/logrotate.d/apache (738 bytes, patch)
2000-05-02 02:58 UTC, James Ralston
no flags Details | Diff

Description James Ralston 2000-05-02 02:54:33 UTC
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.

Comment 1 James Ralston 2000-05-02 02:58:59 UTC
Created attachment 222 [details]
patch for /etc/logrotate.d/apache

Comment 2 Nalin Dahyabhai 2000-05-02 18:18:59 UTC
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

Comment 3 vek 2000-08-18 08:12:26 UTC
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.


Comment 4 James Ralston 2000-09-05 02:26:35 UTC
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,

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