Logrotate Configuration for Apache HTTPD on CentOS

apache-2.2httpdlogrotate

I'm running Apache 2.2.3 on CentOS 5.5 and just noticed the following logrotate postrotate configuration in /etc/logrotate.d/httpd:

postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript

Since this is set to run once per week, it does a hard reload for Apache, which seemingly kills all connections (is this right? I'm not an expert). Would it be safer to change the postrotate script to a graceful restart instead?

/usr/sbin/apachectl graceful > /dev/null

This is the postrotate behavior I already have for my virtual hosts. I don't understand why the httpd rotate scripts needs to do a hard reload.

Any advice on how to configure this properly will be greatly appreciated.

Thanks,
Ralph

Best Answer

No, the '/sbin/service httpd reload' command does not kill all connections as it does not initiate a 'hard restart'. CentOS triggers Apache via service, other OSs do via init scripts. For all of them a 'reload' means a graceful restart/sending Apache the USR1 signal:

"The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately."