homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Checking Apache Status

5+ Year Member

Msg#: 3141809 posted 4:25 am on Nov 1, 2006 (gmt 0)

I am planning to write a script that will execute to check if apache is UP and running, and try to restart it automatically if it is down, and will be putting this script to cron and run it every n minutes.

But, I was wondering how I should be checking apache status? Should I make a request to some dummy file, or check the processes via ps -ef, etc? What is the easiest and fastest (hence least costly) way of doing this?




WebmasterWorld Senior Member 10+ Year Member

Msg#: 3141809 posted 2:59 pm on Nov 1, 2006 (gmt 0)

You should be able to check the status with:

/etc/init.d/httpd status

(or whatever your apache start file is)

do that and you'll get a result similar to

httpd (pid 13149 13103 13102 13101 13099 13098 13097 13095 13018 13017 13015 13014 13000 12963 12928 10986) is running...

If you run that command when it is down you'll get:

httpd is stopped

You could easily run the command and pipe and grep the output to detect either running or stopped. If stopped then issue an an httpd start.

An easier alternative is Webmin System and Server Status monitor. You can set the apache status to be checked every minute, hour, day and then run a command such as start apache, email you etc.

[edited by: Frank_Rizzo at 3:00 pm (utc) on Nov. 1, 2006]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved