所以我知道以下命令会导致Windows服务在30秒后重启。
sc failure %SERVICE_NAME% reset= 60 actions= restart/30000
在这篇文章中:https://technet.microsoft.com/en-us/library/cc742019.aspx#BKMK_examples
他们有以下示例命令:
sc failure myservice reset= 3600 reboot= "MyService crashed -- rebooting machine" command= "%windir%\MyServiceRecovery.exe" actions= restart/5000/run/10000/reboot/60000
有人可以解释重启动作的作用吗?
我的猜测是它首先广播reboot参数中指定的消息,然后在命令参数中运行可执行文件。
答案 0 :(得分:0)
键入sc failure /?
会显示内置帮助:
DESCRIPTION:
Changes the actions upon failure
USAGE:
sc <server> failure [service name] <option1> <option2>...
OPTIONS:
reset= <Length of period of no failures (in seconds)
after which to reset the failure count to 0 (may be INFINITE)>
(Must be used in conjunction with actions= )
reboot= <Message broadcast before rebooting on failure>
command= <Command line to be run on failure>
actions= <Failure actions and their delay time (in milliseconds),
separated by / (forward slash) -- e.g., run/5000/reboot/800
Valid actions are <run|restart|reboot> >
(Must be used in conjunction with the reset= option)
如您所料,reboot
选项指定要在重新启动时广播的邮件。
reboot
中的actions
操作会导致计算机重新启动。