Hi, I'm looking for a script to put on crontab that check if my domain is on, otherway it restart apache.

Sometimes my apache get freeze and I need to manually restart it.

I found many scripts that check if httpd is running, but in my case apache is working but none can connect to it.

How can I check if it's working and I can connect to my web pages?

My actually code is:

Code: 
#!/bin/bash
    # Apache Process Monitor
    # Restart Apache Web Server When It Goes Down
    # -------------------------------------------------------------------------
    # Copyright (c) 2003 nixCraft project <http://cyberciti.biz/fb/>
    # This script is licensed under GNU GPL version 2.0 or above
    # -------------------------------------------------------------------------
    # This script is part of nixCraft shell script http://en.wikipedia.org/wiki/Shell_script  collection (NSSC)
    # Visit http://bash.cyberciti.biz/ for more information.
    # -------------------------------------------------------------------------
    # RHEL / CentOS / Fedora http://en.wikipedia.org/wiki/Fedora  Linux restart command
    RESTART="/sbin/service httpd restart"

    # uncomment if you are using Debian / Ubuntu Linux
    #RESTART="/etc/init.d/apache2 restart"

    #path to pgrep command
    PGREP="/usr/bin/pgrep"

    # Httpd daemon name,
    # Under RHEL/CentOS/Fedora it is httpd
    # Under Debian 4.x it is apache2
    HTTPD="httpd"

    # find httpd pid
    $PGREP ${HTTPD}

    if [ $? -ne 0 ] # if apache not running
    then
     # restart apache
     $RESTART
    fi
Thanks...
skinner Reviewed by skinner on . Check if Apache is ON Hi, I'm looking for a script to put on crontab that check if my domain is on, otherway it restart apache. Sometimes my apache get freeze and I need to manually restart it. I found many scripts that check if httpd is running, but in my case apache is working but none can connect to it. How can I check if it's working and I can connect to my web pages? My actually code is: Rating: 5