Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For development purposes, I'm running an Apache server on my windows machine. Its very non-critical, but sometimes I'll be running processes that take a long time and Apache will stop server requests. Restarting the Apache service works just fine when this happens.

Is there a script out there somewhere that can detect if Apache is failing to load pages and then restart the service if it is?

It would probably look something like this:

LOAD localhost/index.php
share|improve this question
" I'll be running processes that take a long time and Apache will stop server requests. " Is this with respect to Apache? Or are you referring to other external process which place highload on your machine, blocking Apache? – Jason Huntley Apr 4 '12 at 20:14
They place maybe a medium load on the machine. Apache seems to be locking up periodically due to whatever is going on. Sometimes it crashes, sometimes it just stops servicing requests. – Chris Dutrow Apr 5 '12 at 2:07
up vote 3 down vote accepted

You can do it externally with WGet.exe and the scheduler service:

wget -o:foo http://localhost/page_of_interest.php || powershell.exe restart-service apache

Not sure which OS you're using, so YMMV with this task scheduler config:

Assume your batch script is called c:\bin\files\ca.cmd, type this at the command line:

schtasks.exe /create /u administrator /p password /sc minute /mo 2 /tn "Check Apache every 2 minutes" /tr c:\bin\files\ca.cmd
share|improve this answer
That's awesome, thanks so much! Do you know how I could set this command to run every minute or so? – Chris Dutrow Apr 5 '12 at 2:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.