Link to home
Start Free TrialLog in
Avatar of craylord
craylord

asked on

Script to restart server if pinging gateway fails.

I'm looking for a script that will run in the background that will check to see if the gateway is pingable. If not, it sends a reboot command. shutdown /f

This is for a Windows 2003 server that is continously dropping its network connections due to an issue with an application. This should be a windows batch file. I don't have the time to mess with another language. Something simple enough where I can test by unplugging the network cable and see the process in action. Thank you!
ASKER CERTIFIED SOLUTION
Avatar of RichardSlater
RichardSlater
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sirbounty
I would only add - don't limit it to 1 packet result - you're asking for unexpected reboots if so, leave it at the default of 4, since a packet could be dropped for any other reason.


ping servername
if %errorlevel%==1 shutdown /f /r /t 30

will give you a 30 second timer, and force all open apps to close...
Avatar of craylord
craylord

ASKER

Is there any easy way to query the gateway so it doesn't have to be hard coded?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I went with the default ping (4 response checks). I also configured to run it as a service. ty very much.
Hello Experts...

I need a script that pings some ip, if this ip is unreacheable than the script will delete some static routes. When the IP is reachble again the routes needs to be add again.

Anybody knows a way ?

Regargs

Tullio