zoukankan      html  css  js  c++  java
  • Windows Services Recovery option doesn't work ... or I don't understand it RRS feed

    Windows Services Recovery option doesn't work ... or I don't understand it

    You could have a look at the blog post below, see if it helps you!

    https://blogs.msdn.microsoft.com/jcalev/2008/01/10/some-tricks-with-service-restart-logic/

    " First failure: what should occur the first time the service fails.  Valid options are "Take No Action", "Restart the Service", "Run a Program", and "Restart the Computer".


    Second failure: same options the second time a service fails


    Subsequent failures: same options for any subsequent failure


    Reset fail count after: the number of days the service must be running before the failure count is reset


    Restart service after: the amount of time in minutes to wait to restart the service


    This is very nice, but it is very easy to misunderstand what these values actually do.  I have seen a number of services (and I tried this myself) set these values to 0 days and 0 minutes.  The problem is your service will continually restart if you set the failure count to reset after 0 days, if the service at least started correctly.  The result is only the first option ("first failure") will ever be run. 


    To fix this, set the failure count to reset after one day.  The drawback to this approach is your service may stay stopped after failing several times but this likely means something is toast anyways.


    One thing also to take into account is not all services will work with the reset logic - or in other words just setting the recovery options on any service does not guarantee that it will restart.  In order for the service to restart, it must exit abnormally.  This generally means the service must exist with a non-zero exit code and the service status must not be stopped (note: this has changed for Vista - it is possible to set the service status to stopped and provide an exit code to trigger the restart logic).

    Best regards,
    Leon

    How can I automatically restart a Windows service if it crashes?

    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?

    回答

    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
    

    What is Blat?
    Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usenet using NNTP. 

    Trying to set services to restart ANYTIME they fail. I need this setting to NEVER Expire?

    回答1

    The reset failure count is the "trigger" for the second recovery action. IF its is set to 0 it will never trigger the second condiction.

    回答2

    Setting "Reset fail count after" to 0 means "reset the fail count to 0 after each failure" until a reboot occurs.

    The 0 effectively disables both, the "second failure" and "subsequent failure" actions and you will always get the "first failure" action, until you reboot the machine.

    Clarification on Windows Service Recovery Actions Settings

    问题

    I am looking at the recovery actions settings and there are a couple of things that I need clarified.

    If I have 0 days as my reset fail count after, and have the following as my actions:

    1. Restart the Service - on first failure
    2. Restart the Service - on second failure
    3. Reboot the Computer - on subsequent failures

    Does the fail count get reset on a successful restart of the service?

    Does the fail count get reset on the first failure? Hence never having a chance to perform the second or third actions?

    On the third successive failure, the computer gets rebooted, the service get started and then fails again; would this reboot the computer again?

    Thanks in advance!

    Jaime

    回答1

    Setting "Reset fail count after:" to 0 means "reset the fail count to 0 after each failure".

    This effectively disables both the "second failure" and "subsequent failure" actions and you will always get the "first failure" action.

    回答2

    I've tested that fail count on windows XPE. When the service run and I make it fail with "End Process" of the Windows task Manager. I have defined 3 recovery actions:

    1. restart service
    2. reboot
    3. run a program
    • On the first "end of process", the service is well restarted. OK.
    • On the second "end of process", the compuer is rebooted. OK.
    • After the reboot, if I end the process again, it is restarted and if I end it again, the computer is rebooted.

    So it seems that this failure counter is reset after every reboot of the computer...

    I precise that my fail count is configured to reset after 1 day.

    RRS feed

  • 相关阅读:
    .Net框架集WebClient类向WinCE平台上传文件(FTP方式)延迟15秒释疑
    WinCE系统下BootLoader的开发
    cf1154G 埃氏筛应用
    关于调用C kernel functions
    Download internal table data into Excel(比使用OLE自己填写速度要快)
    Internet+大会和Google请来的大师
    回到Mountain View
    关于F4 Help帮助窗口的参数F4METHOD的设置
    计划策略 MTS部分
    人在Google
  • 原文地址:https://www.cnblogs.com/chucklu/p/15527441.html
Copyright © 2011-2022 走看看