Windows script to detect if Apache is not working and then restart – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, windows, powershell, , .
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 IF LOAD FAILED: RESTART APACHE SERVICE
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:binfilesca.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:binfilesca.cmd