cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Windows service recovery actions via commandline (dbsvc)

Former Member
23,280

I'm installing a Windows Service via dbsvc command that starts our database. This works fine however, when the dbsrv12 process is killed from the task manager (for testing purposes:), it doesn't restart. To solve this, I have to go to Windows' "Services" list and set the "First failure" action on the "Recovery" tab to "Restart the Service" (which was "Take No Action"), which makes the command line installation somewhat pointless.

The question is, can I set these parameters via commandline so that the database restarts when it happens to fail? I could not find any mention in the docs. Any alternative way is welcome.

Accepted Solutions (1)

Accepted Solutions (1)

justin_willey
Participant

You can use the Windows sc command line utility to configure services.

For example, to make restart the action on failure:

sc failure SQLANYs_servicename actions= restart/60000/restart/60000// reset= 240

this will set the failure actions of the database engine service SQLANYs_servicename to re-start after sixty seconds on the first two failures and then do nothing. The reset command re-sets the failure counter after 4 minutes. (NB as Jeff points out the actual service name is "SQLANYs__" in front of whatever you called it!)

You can also use sc config to set things like delayed start-up, service dependencies etc. See sc /? for full details.

justin_willey
Participant
0 Kudos

One thing to note is that the positioning of the equals signs is vital. There must be no space between the keyword (eg "actions" or "reset") and the equals sign, and there must be a space after the equals sign.

Former Member
0 Kudos

Using 'sc' solves it, thanks.

Answers (2)

Answers (2)

graeme_perrow
Advisor
Advisor

No, there is currently no way to do this using dbsvc. I will add it to my list of features to investigate for a future release.

Former Member
0 Kudos

Thanks. It's not critical since there's a way around, but might be easier with a switch=)

jeff_albion
Advisor
Advisor

There is no current way to control this behaviour via dbsvc.

The service restart parameters are specified in the Registry as the "FailureActions" REG_BINARY value. This information is based on the SERVICE_FAILURE_ACTIONS / SC_ACTION data structures although without investigating further, it's difficult to see how these values are related.

You can try creating a service, manually configure it through the Windows Service manager, and then see if copying the REG_BINARY value to another service definition in the Registry.

The SQL Anywhere registry service information can be found underneath:

\\\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\SQLANYs_servicename

Where servicename is the name provided via the "-sn" switch.

You can then apply the registry setting via the "reg" command at the Command Prompt.

Former Member
0 Kudos

I think sc command does necessary updates to the registry. Thanks for the answer.