Rotating web server logs without restarting Apache
Holger Kipp
hk at alogis.com
Sat Nov 26 01:12:45 GMT 2005
On Fri, Nov 25, 2005 at 04:38:14PM -0800, Dan O'Connor wrote:
> >Every time my httpd-access.log file is rotated I need to restart
> >Apache, otherwise it won't write into the new httpd-access.log file.
>
> In /etc/newsyslog.conf:
>
> /var/log/httpd-access.log 644 4 100 * J
> /var/run/httpd.pid 30
> /var/log/httpd-error.log 644 4 100 * J
> /var/run/httpd.pid 30
>
> This will signal apache to do a graceful restart following a log
> rotation...
Don't compress those files in this case! For a comprehesive
explanation see
http://www.freebsddiary.org/rotatelogs.php
but it boils down to the following: if sending SIGUSR1 to apache,
not all children might have finished writing to the log files
immediately, so the file might still be written to (it was not
copied, but merely renamed by newsyslog) for some time (depending
on the requests, client bandwidth, delays etc. this might be a few
minutes for http-connections to finish).
Regards,
Holger Kipp
alogis AG, Berlin
More information about the freebsd-stable
mailing list