7

I am using the following command to configure the service failure recovery

sc failure "service" actions= ""/60000/restart/60000/run/120000 reset= 60 command = "\"c:\\windows\notepad2.exe

(used notepad2.exe just for testing)

From the Microsoft documentation here:-

Actions

This field contains an array of integer values that specify the actions taken by the SCM if the service fails. Separate the values in the array by [~]. The integer value in the Nth element of the array specifies the action performed when the service fails for the Nth time.

So, what I am getting from this is the count of failure will decide the action => For first failure Actions[0] will be executed and for the second Actions[1] will be executed and for all subsequent failures Actions[2] will be

I have following configuration for the service for testing this behavior:-

enter image description here

Then I tried killing the process under which service is running by using taskkill.

Here is the first log enter image description here

Then I tried starting the service manually. enter image description here

Then again I tried killing the service after ~ 2 mins ( => the reset count will set failure count to 0 as it is configured to 1 minute).

Here is the log for the error enter image description here

In above figure, it is clear that why count is resetting to 0 because reset setting we have given60 sec and our service was running more than 2 mins.

But the action described for recovery is wrong as Restarting the service is the action for the second failure not for the first failure.

So why the count for failure is coming 1 but the action for recovery is the action corresponding to the second failure action?

OldSchool
  • 2,123
  • 4
  • 23
  • 45

1 Answers1

0

I was just playing around with a similar issue, and after I set the "Reset fail count after:" to "1" day, it seems to be working. A possible explanation is that by setting the "Reset fail count" to 1 day, it will not reset the fail count back to 0 after the first fail (which is you stopping and restarting the service manually), and lets it cycle through the rest of the actions (depending on conditions/actions). Your mileage may vary.

BillA
  • 11
  • 2