DISQUS

Tech-Recipes: Restart Apache without closing open connections | Apache web server | Tech-Recipes

  • bofh468 · 6 years ago
    Failing to find apachectl, one could just find the PID of the parent httpd process and send a -USR1 signal to it.

    For example:


    $ ps -ef | grep httpd
    root 17723 1 0 Sep23 ? 00:00:01 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3666 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3667 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3668 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3669 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3670 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3671 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3672 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
    apache 3673 17723 0 Nov09 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D

    $ kill -USR1 17723



    a -USR1 signal will cause any new children to run with a new configuration, but leave the current children running as-is. A -HUP signal will kill off all current children and cause new requests to be serviced under the new configuration.

    Of course, one could be a little more sophisticated:



    $ ps -ef | grep httpd | grep root | awk '{print $2}' | xargs kill -HUP




    That said, apachectl is a lot cleaner.