Bug 11167 - a better way to code /etc/logrotate.d/apache
a better way to code /etc/logrotate.d/apache
Product: Red Hat Linux
Classification: Retired
Component: apache (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2000-05-01 22:54 EDT by James Ralston
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-05-02 14:18:36 EDT
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-01 22:58 EDT, James Ralston
no flags Details | Diff

  None (edit)
Description James Ralston 2000-05-01 22:54:33 EDT
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-01 22:58:59 EDT
Created attachment 222 [details]
patch for /etc/logrotate.d/apache
Comment 2 Nalin Dahyabhai 2000-05-02 14:18:59 EDT
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 04:12:26 EDT
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-04 22:26:35 EDT
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.