Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

1.How can i run a Batch file so that it would ping the service in remote machine every hour and if the service is down it would automatically restart the service.Both machines OS is windows XP. 2. Is there any way where i can run the batch file in linux for the same purpose. Please guide me as am not sure where to start. would really appreciate your help.

share|improve this question
Do you need a Linux script to check service(s) on Windows XP machines? If yes, you need cygwin to provide SSH access, then I could post a script example. –  weeheavy Oct 18 '10 at 9:07

2 Answers 2

Which service do you want to monitor?

Something like this should get you going:

set service=fax
for /f "tokens=3" %%a in ('sc query "%service%"^|find "STATE"') do (
    if %%a==4 goto eof
    goto stopped
sc start %service%

There's also this:

NET START | FIND "Fax" > nul
IF errorlevel 1 NET START Fax

Use scheduled tasks to run it on whichever XP machine you want. IF you need one machine to monitor the other you can use PSEXEC from the PSTools pack.

Actually, scratch that, PSTools has a PSService command that might be better than hacking together something with PSEXEC and SC.

I don't know how easy it would be to do from a linux machine but I suspect not very..

share|improve this answer

For Linux there are two such programs available

  1. monit
  2. supervisord
share|improve this answer

Your Answer


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