I need to watch three Windows Server services and restart them if they stop, even when no one is logged in. The built-in recovery options haven’t been reliable for me. Is a scheduled script a reasonable fix, or should I troubleshoot service recovery first?
Can I monitor and restart services when nobody is logged in?
Answers
A script can run without an interactive user session. You could set it up as a scheduled task under an account with the needed permissions, or as Local System if that fits your security requirements. Have it check the specific services and restart only those that are stopped.
Before adding another layer, though, check why the recovery actions aren’t working. Confirm the failure actions are configured as intended and review the service and system logs around a failure. A service that stops because a dependency or the whole system is unhealthy may not stay up just because it gets restarted.
Reply to this answer
For Windows, I’d start with the service’s recovery settings rather than polling it forever. If those settings are genuinely not firing, verify the configuration and inspect the relevant event logs. That may show whether Windows detected a failure or whether the service is hanging without actually stopping.
Reply to this answer
Yes, a scheduled task can do this with nobody logged in. Set the task to run whether a user is logged on or not, choose an account with rights to control the services, and use a sensible interval. Log what it finds and whether a restart succeeds, so you can tell whether this is fixing the issue or just hiding it.
Reply to this answer
One gotcha: checking only whether a service is running won’t catch every failure. A process can remain marked as running while the service is unresponsive. If that’s what’s happening, a basic restart script may not notice it, so first pin down what “stopped” means in this case.
Reply to this answer
Add your answer
Answers are reviewed before publication.
wobble.audit:
That makes sense. I’ll check the recovery configuration and logs first, then use a task only if there’s a clear gap.