Posted by: Mangesh_Linux_Administrator | August 18, 2010

Shell Script To Auto Restart HTTPD (If Goes Down)


Set con job for this script:
*/5 * * * * /path/to/script.sh >/dev/null 2>&1
===========================================================
SCRIPT:
# for RHEL / CentOS / Fedora Linux restart command
RESTART="/etc/init.d/httpd restart"
 
#path to pgrep command
PGREP="/usr/bin/pgrep"
 
# Httpd daemon name
HTTPD="httpd"
 
# find httpd pid
$PGREP ${HTTPD}
 
if [ $? -ne 0 ] # if httpd not running
then
 # restart httpd
 $RESTART
fi
Advertisements

Responses

  1. Hello there, just became aware of your blog through Google, and found that it is truly informative.
    I am going to watch out for brussels. I will be grateful if you continue
    this in future. Lots of people will be benefited from your
    writing. Cheers!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Categories

%d bloggers like this: