[ale] [HELP] - errors rotating logs

Gary Maltzen maltzen at mm.com
Sun Nov 7 16:36:13 EST 1999


The problem is that httpd doesn't close and reopen log files in response to SIGHUP; you have to kill and restart httpd in order to close the logfiles. The reason they are all empty is that httpd is logging to the one you just tried to rotate out of existence - and that's also why you got the error.

Have you tried running your logs through syslogd or through a pipe (like 'httpdlogs') so that you don't have to kill and restart httpd?

For example in httpd.conf you could have

Errorlog syslog:local0
TransferLog "|/usr/local/sbin/httpdlogs /var/log/httpd/access_log"

And /usr/local/sbin/httpdlogs would be a Perl script which closes and reopens a log in response to SIGHUP

#!/usr/bin/perl
use sigtrap HUP;
sub openOutput {
  open(OUTPUT, ">>$output"); select OUTPUT; $| = 1;
}
$SIG{HUP} = \&openOutput;
$output = $ARGV[0];
if (! $output ) { $output = '/var/log/httpd/httpd_log'; }
&openOutput;
while(<STDIN>) { print; }

and finally the logrotate script would read

  postrotate
    /usr/bin/killall -HUP httpdlog
  endscript


>errors occurred while rotating /var/log/httpd/access_log
>
>httpd: no process killed
>error running postrotate script
>
>I also looked at the /etc/logrotate.d/apache file as suggested before.
>It shows the following for /var/log/httpd/access_log:
>
>/var/log/httpd/access_log {
>     postrotate
>         /usr/bin/killall -HUP httpd
>     endscript
>}
>
>Can someone point me in the right direction to finding out what's
>wrong?  I have a couple of theories, but I don't know if my logic is
>sound.
>
>First, is postrotate a script that I can find on my system somewhere
>or do the following lines denote it AS the postrotate script itself?
>             postrotate
>                 /usr/bin/killall -HUP httpd
>             endscript






More information about the Ale mailing list