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

Question

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

iblazevic358@gmail.com 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  IsAlive.sh

     

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

     

    then run command

    chmod +x IsAlive.sh

    Then run it with crontab for example, every 2 minute

     

    */2 * * * * ./isAlive.sh

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

Post your Answer

 Prev question