Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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."

share|improve this answer
    
Thanks for your detailed reply. When I look at the server-status page, however, the Server Uptime usually resets after 7 days. Is this normal behavior then? I just want to make sure my Apache isn't restarting more than necessary. –  Ralph Apr 24 '11 at 4:19
    
Hmm, if the server uptime at the server-status page gets reset every 7 days, then your Apache seems to get indeed restarted regularly. Did you checked your /etc/crontab as well as the scripts in the /etc/cron.weekly/ folder? –  desasteralex Apr 24 '11 at 5:21
add comment

The original answer is not correct. The initscript "reload" just passes the reload command to apachectl. A reload sends SIGHUP to httpd, which immediately terminates the child processes and does interrupt currently connected clients: http://httpd.apache.org/docs/current/stopping.html#hup

See a bug filed against the RHEL httpd package: https://bugzilla.redhat.com/show_bug.cgi?id=480624

The reason graceful is not used in the logrotate script is because there's no way to guarantee the the child processes have stopped: http://httpd.apache.org/docs/current/stopping.html#graceful

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.