Bug 11167 - a better way to code /etc/logrotate.d/apache
Summary: a better way to code /etc/logrotate.d/apache
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: apache
Version: 6.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Nalin Dahyabhai
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
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:
Clone Of:
Environment:
Last Closed: 2000-05-02 18:18:36 UTC
Embargoed:


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
else
    true
fi

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
else
	true
fi

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.


Villy

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,
though.



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