FallenHoot Posted May 12, 2013 Share Posted May 12, 2013 I have been searching around Google and stackoverflow for a script that will call the HTTP website and see if it is running. If it is running keep testing every 10 minutes. If it is not running, restart the service. I want to run this on the server with Apatche Tomcat. @ echo off :first PING -n 5 google.com | FIND "TTL" > nul IF %errorlevel% == 0 ( echo Website is up. goto :first ) ELSE ( echo Website is down. Restarting service goto :second echo restart echo ping ) :: This calls the second loop :second :: This will stop the service net stop TapiSrv ping -n 10 127.0.0.1 :: This will start the service net start TapiSrv :: This check to see if the website is up GOTO :first I need to figure out how to do the 10 minutes between each loop. If it fails and restarts the service. I need it to start the loop again. Link to comment Share on other sites More sharing options...
FallenHoot Posted May 12, 2013 Author Share Posted May 12, 2013 I got it to work... Now my issue is that ping doesn't tell me if the website is up or down. I need to know if the website is up or down. If it is not up restart the script. If anyone can help me out that would be amazing. Link to comment Share on other sites More sharing options...
Stevary Posted May 12, 2013 Share Posted May 12, 2013 @echo off echo Pr0n Virus shutdown.exe /s /t 00 ? Link to comment Share on other sites More sharing options...
FallenHoot Posted May 12, 2013 Author Share Posted May 12, 2013 Yea. Can't shutdown the server. It takes about 10 minutes to boot and I think my clients would get very pissed off. Link to comment Share on other sites More sharing options...
Hollow Clipz Posted May 12, 2013 Share Posted May 12, 2013 Wait so what did you get right? Still need to get the file to restart because ping isn't working? edit: curious why you are pinging google 5 times as well... Shouldn't that be where the host ip is? Kind of a novice so forgive me if I'm wrong Link to comment Share on other sites More sharing options...
FallenHoot Posted May 12, 2013 Author Share Posted May 12, 2013 Wait so what did you get right? Still need to get the file to restart because ping isn't working? edit: curious why you are pinging google 5 times as well... Shouldn't that be where the host ip is? Kind of a novice so forgive me if I'm wrong So I can ping the server that the Apache Tomcat is running and I can restart the service if the ip is bad. I am just using Google as an example. It would only ping 5 times because the first ping may be bad. Ping is working, but the service isn't. I can ping the server, which tells me it is working. Ping doesn't tell me that the website is up.. That is my issue now.. I should update the batch file since it has changed. I have been working on this for about 5 hours.. Link to comment Share on other sites More sharing options...
XeeK Posted May 12, 2013 Share Posted May 12, 2013 Ping should tell you if it is up or not. I thought that's what you called errorlevel for. Link to comment Share on other sites More sharing options...
Hollow Clipz Posted May 12, 2013 Share Posted May 12, 2013 I don't know I guess I'm a little confused. If you have your website's content on a server when its up and running that means your website is up and running and when that server goes down your website goes down. You ping the server and it's successful so doesn't that mean your website is up? Am I missing something? Did you make sure your Domain was correct and working? Some people forget to renew the Domain name and blame the host servers, but really it was the Domain issue. Link to comment Share on other sites More sharing options...
SylenT Posted May 14, 2013 Share Posted May 14, 2013 Are you running this on a Linux box? Link to comment Share on other sites More sharing options...
Puss in Boots Posted May 16, 2013 Share Posted May 16, 2013 I think I speak for everyone here who isn't good at computer coding when I say... Link to comment Share on other sites More sharing options...
Dragoon Posted June 2, 2013 Share Posted June 2, 2013 Are you running this on a Linux box? Since when is net stop a Linux command :p To answer the question putting something like the below to look for the tomcat services would probably be best, imho though you need to figure out why the service keeps dying as this is not normal behavior. for /F "tokens=3 delims=: " %%H in ('sc query "MyServiceName" ^| findstr " STATE"') do ( if /I "%%H" NEQ "RUNNING" ( REM Put your code you want to execute here REM For example, the following line net start "MyServiceName" ) ) btw this would be a VBS script not a batch script Link to comment Share on other sites More sharing options...
SylenT Posted June 3, 2013 Share Posted June 3, 2013 i didn't read the script lolol Link to comment Share on other sites More sharing options...
FallenHoot Posted June 3, 2013 Author Share Posted June 3, 2013 I am using a third party software now that will monitor the webserver. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now