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!
Windows BatchMicrosoft Server OSMicrosoft DOS

Avatar of undefined
Last Comment
tullioc
ASKER CERTIFIED SOLUTION
Avatar of RichardSlater
RichardSlater
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of sirbounty
sirbounty
Flag of United States of America image

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
Avatar of sirbounty
sirbounty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of craylord
craylord

ASKER

I went with the default ping (4 response checks). I also configured to run it as a service. ty very much.
Avatar of tullioc
tullioc

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

Microsoft Server OS
Microsoft Server OS

The Microsoft Server topic includes all of the legacy versions of the operating system, including the Windows NT 3.1, NT 3.5, NT 4.0 and Windows 2000 and Windows Home Server versions.

59K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo