Register
It is currently Tue Sep 02, 2014 8:11 pm

Simple script to restart apache.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 29, 2008 7:00 pm   

Joined: Wed Jul 04, 2007 5:11 pm
Posts: 8
Location: new york
Here is a small script to restart The apache server.

Code:

#!/bin/bash

pgrep http > /dev/null

if [ $? -ne 0 ] ; then
     /etc/init.d/httpd start
fi



Explanation the pgrep runs if the command is successful the return exit status of the command pgrep http will return 0
then with that condition met the command /etc/init.d/httpd start will be sent to start apache.

Very simple and can be tweaked to almost any type of daemon service. MySQL , Sendmail

If there is something wrong with this script let me know. I am still a newbie.

Thanks


Top
 Profile  
 PostPosted: Mon Mar 03, 2008 5:40 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
presumably you intend this to be run from crond or similar. Note that if your webserver crashed (assuming that's why it's not running) you could worsen the issue by auto restarting it every 5m depending on how you configure crond. I suggest using Nagios for this type of monitoring.

http://www.nagios.org/


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP