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.

I have a Windows service that exits unexpectedly every few days. Is there a simple way to monitor it to make sure it gets restarted quickly if it crashes?

share|improve this question

5 Answers 5

Under the Services application, select the properties of the service in question.

View the recovery tab - there are all sorts of options - I'd set First & Second Failure to Restart the Service, Third to run a batch program that BLAT's out an email with the third failure notification.

You should also set the Reset Fail Count to 1 to reset the fail count daily.

EDIT:

Looks like you can do this via a command line:

SC failure w3svc reset= 432000  actions= restart/30000/restart/60000/run/60000
SC failure w3svc command= "MyBatchFile.cmd"

Your MyBatchFile.CMD file can look like this:

blat - -body "Service W3svc Failed" -subject "SERVICE ERROR" -to Notify@Example.com -server SMTP.Example.com -f Administrator@Example.com
share|improve this answer
1  
All good stuff, but +1 especially for the email notification advice and the command-line stuff. –  Darth Satan Jul 31 '09 at 18:27

Open Services.msc, double-click on the service to open the Properties of the service, there is a Recovery tab and those settings should allow you to restart the service upon failure.

share|improve this answer

I am using ServiceKeeper on my windows 2008 server at HostForLife.eu and it works very good. Previously, I had a review on ServiceHawk, but I prefer to use ServiceKeeper for its easier management and interface.

share|improve this answer

This was my answer on a similar thread Hope this helps...

You can schedule a simple vbs script like this one to restart periodically the service on the computer if needed.

strComputer = "." 
strSvcName = "YOUR_SERVICE_NAME" 
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objService = objWMI.Get("Win32_Service.Name='" & strSvcName & "'")
If objService.State= "Stopped" Then
    objService.StartService()
End If


share|improve this answer

Someone asked a similar question over at Super User: You could install a tool that monitors windows services. Something like Service Hawk would help you keep the services started, or allow you to schedule automatic restarts (possibly during the night) to keep the service running smoothly.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.