How to check if Apache is Live , if not , then restart it?


Hi, I'm using Django with Apache on webfaction web hosting and sometime my web app use to much  RAM memory and then Apache stop working..  Can someone tell me how to create bash script which will check  if apache server is LIVE if not then restart it .. Dec. 22, 2014, 5:57 p.m. 1 Answer

Answers ( 1 )

  1. Dec. 22, 2014, 6:17 p.m.

    You can create bash script .. for example


    if [ `ps -ef | grep "apache2/bin/httpd.worker" | grep -v grep | wc -l` -gt 1 ] ; then
    echo "RUNNING...."
    echo "NOT RUNNING..."


    then run command

    chmod +x

    Then run it with crontab for example, every 2 minute


    */2 * * * * ./

Warning! You are not logged in.
Your answer will be published as Guest user.

Post your Answer

 Prev question