Your Always-On Service Is Secretly Waiting for You to Log In

Date:

The scheduled task’s status says “Ready.” The service says “Running.” Everything looks healthy. Then the machine reboots at 3 a.m. for an update, nobody signs in, and the thing that is supposed to run around the clock quietly isn’t. When you log in the next morning, it springs back to life, so it looks fine again. The common thread is the login.

The short answer: a surprising number of always-on services are tied to an interactive user session without saying so. A GUI app you think of as a background service, a scheduled task with a logon trigger, a task set to run “only when the user is logged on,” a process that inherits your session token: each of them lives and dies with your login. They pass every test you run because you run the tests while logged in, which is the one condition that hides the dependency. The fix is to sever it: run the work as a true service, turn on the app’s unattended mode, or give the task a boot trigger and “run whether the user is logged on or not.” And the only honest test is to reboot, not log in, and confirm from somewhere else that it is still running.

The reason this bug is so durable is that it is invisible during development. You install the thing, you’re logged in. You test it, you’re logged in. You reboot to check it survives, and then, out of habit, you log in to look. At that instant the dependency you’re trying to catch is satisfied, so everything works, and you conclude it’s solid. The failure only appears in the one situation you never reproduce on purpose: the machine is up and nobody is signed in.

The GUI app that is not the service you think it is

Many background tools ship as two pieces: a service that does the real work, and a tray application that shows status and holds settings. It is easy to assume the service is what keeps things running. Sometimes it isn’t. Some tools only keep their connection alive while their GUI is running, or tear down state when the interactive user logs out.

A common example is a mesh-VPN client. By default, on some setups, it stays connected only while you are logged in; when you log out or the tray app stops, the tunnel drops. The provider’s own answer is an unattended mode that keeps the connection up with no user signed in. If you’ve ever found a remote machine unreachable after a reboot until someone logged into its console, this is usually why, and the fix is one setting, not a restart:

# Keep the connection up with no user logged in (example: Tailscale)
tailscale up --unattendedCode language: Bash (bash)

The tell is the shape of the dependency, not the specific product: if a service’s liveness tracks a tray icon or a logged-in session, treat it as not always-on until you’ve told it to run without one. This is the same category of surprise as a success message that isn’t confirmation: the status you’re reading (“Running,” a green tray icon) reports on the wrong thing.

The scheduled task that only wakes up when you do

The other common culprit is the task scheduler, and it has two separate traps in one dialog. (The pattern isn’t unique to the operating system’s scheduler, either: a web app’s scheduler can mislead the same way. WordPress cron fires on page visits rather than a real clock, so a site with no traffic quietly runs nothing on time.)

The first is the trigger. A task triggered “at log on” runs when a user signs in. That is perfect for something that should follow your session, and exactly wrong for something that should run on a headless, rebooted, nobody’s-here machine, because no log-on event ever happens there. If the work must run after an unattended reboot, its trigger has to be at startup, not at log on.

The second is the security context: “Run only when the user is logged on” versus “Run whether the user is logged on or not.” The first is the default and it does exactly what it says: no session, no run. The second runs the task in the background under the account’s credentials with no interactive desktop.

# The trap: runs only when a user signs in, only while signed in
schtasks /Create /TN MyJob /TR "C:\path\job.cmd" /SC ONLOGON

# The fix: runs at startup, no login required
schtasks /Create /TN MyJob /TR "C:\path\job.cmd" /SC ONSTART /RU SYSTEM

# Or, to run as yourself without a session ("run whether logged on or not"):
schtasks /Create /TN MyJob /TR "C:\path\job.cmd" /SC ONSTART /RU <user> /RP <password>Code language: PHP (php)

The /RU SYSTEM form (or /RU <user> /RP <password>, which is the command-line way to say “run whether logged on or not”) is what detaches the task from your session. One caveat worth knowing: a task running with no interactive desktop can’t pop up windows, so if the job genuinely needs a GUI, that is a design problem to solve, not a checkbox. The reference for the flags is Microsoft’s schtasks documentation.

A subtle, nasty version of this: the task’s status still reads Ready, and a manual “Run” from the console works perfectly, because when you click Run you are, again, logged in. “Ready” and “runs when I trigger it by hand” are not the same as “runs on its own when no one is here.” It is the same gap as a running process that isn’t doing the job you think: the state you can see is not the state that matters.

More ways to keep it running

The fixes above sever the login dependency, which is the right goal. A few more levers belong in the same toolbox, roughly in order of preference.

  • Set the service to start automatically. If the work already runs as a service but doesn’t come up after a reboot, its start type may be Manual. Set it to Automatic so the system launches it at boot with no one signed in. This is exactly how a well-behaved background tool stays up: its backend installs as an auto-start service, so it reconnects at boot on its own.
  • Wrap a plain program as a service. If the thing isn’t a service at all, a service wrapper (the open-source NSSM is a common one) can run any executable as one, so the system starts and supervises it at boot. That turns “a program someone has to launch” into “a service that is just up.”
  • Keep the machine awake. Always-on also loses to a machine that goes to sleep. On a box meant to run unattended, disable sleep and hibernate so it doesn’t quietly drop off the network an hour after you walk away.
# Make an existing service start at boot (note the required space after "start=")
sc config <ServiceName> start= auto

# Stop an always-on machine from sleeping or hibernating on wall power
powercfg /change standby-timeout-ac 0
powercfg /change hibernate-timeout-ac 0
Code language: Bash (bash)

Starting it is only half the job; keeping it up once it has started is the other half.

  • Restart it if it crashes. Auto-start brings a service back after a reboot, but does nothing if it dies mid-run. A service’s recovery settings restart it automatically on failure, which turns a silent crash into a brief blip instead of an outage that lasts until someone notices.
  • Mind the boot order. A service set to Automatic can start before the network, or another service it depends on, is ready, then fail to bind or connect, and stay down until the next manual start. This is the maddening case where the service is set to auto-start and still isn’t up after a reboot. Give it a delayed start, or an explicit dependency on what it needs, so it waits instead of racing.
  • Watch it with a keepalive. If the thing can’t be a service at all, a scheduled task on a short interval can check whether it’s running and relaunch it if not. It’s cruder than a service’s own recovery, but it covers a GUI-only app that the service options can’t.
# Restart the service on each failure, five seconds apart (reset the counter daily)
sc failure <ServiceName> reset= 86400 actions= restart/5000/restart/5000/restart/5000

# Delay the start until after the network and core services are up...
sc config <ServiceName> start= delayed-auto
# ...or make it wait for a specific service by name
sc config <ServiceName> depend= <OtherService>
Code language: Bash (bash)
  • Auto-login, as a last resort. If a tool genuinely needs an interactive desktop and offers no headless mode, the pragmatic fallback is to make a session always exist: configure the machine to log a user in automatically at startup (a tool like Sysinternals Autologon does this without storing the password in plain text). It works, but understand the trade: anyone with physical access to that machine now gets a logged-in desktop, so use it only on a box that is physically secured. Reach for auto-login only when a tool leaves you no headless option; the choices above are all better.

The only honest test of an always-on service

Because the dependency is satisfied the moment you log in, you cannot verify “always-on” from a logged-in session. There is exactly one test that means anything:

  1. Reboot the machine.
  2. Do not log in. Walk away, or go straight to another device.
  3. From that other device, check that the thing is actually doing its job: the service answers, the sync ran, the connection is up, the queue is draining.

If it only comes alive once you sign in at the console, it was never always-on; it was on-while-you-were. Running this test deliberately, once, after you set something up to run unattended is worth more than any amount of reading a green status while logged in.

The only honest test of "always-on"The login satisfies the hidden dependency, so you can't verify always-on from a logged-in session
1. Reboot the machine

Restart it, so any dependency on a logged-in session is reset to zero.

2. Do NOT log in

Leave it at the sign-in screen. No session – the exact condition that normally hides the bug.

3. Check from elsewhere

From another device, confirm it's doing its job: service answers, sync ran, connection up, queue draining.

If it only comes alive once you sign in at the console, it was never always-on. It was on only while you were.

The short version

“Always-on” is a claim about what happens when nobody is there, so it can only be verified by not being there. GUI-fronted tools, logon-triggered tasks, and “run only when logged on” tasks all pass your tests because you test them logged in, then stop after a reboot no one signs into. Sever the dependency: a true service, the app’s unattended mode, or a startup-triggered task set to “run whether the user is logged on or not.” Then prove it the only honest way, by rebooting, not logging in, and checking from somewhere else that it is still running.

Frequently Asked Questions

Why does my background tool stop when I log out of Windows?

Because it is tied to your interactive session rather than running as a true background service. Some tools keep working only while their tray app or your login is active, and tear down when you log out. Look for an “unattended” or “run as a service” / “keep running when logged out” option in the tool, and enable it; for a mesh VPN that is typically a single unattended-mode setting. If there is no such option, the tool is not designed to run headless, and you’ll need a different approach (run it under a service wrapper, or on a machine that stays logged in).

What’s the difference between a logon trigger and a startup trigger?

A logon trigger fires when a user signs in, so it’s right for work that should accompany your session and wrong for anything that must survive an unattended reboot, where no one signs in. A startup trigger (also called “at system startup”) fires when the machine boots, before and independent of any login. If a task must run on a headless or rebooted machine, it needs a startup trigger, not a logon trigger.

My scheduled task says “Ready” but never runs on its own. Why?

Almost always one of two things: it has a logon trigger (so it waits for a sign-in that never happens on an unattended machine), or it’s set to “run only when the user is logged on” (so it needs an active session). “Ready” means enabled, not running; a manual Run succeeds only because you are logged in when you click it. Switch the trigger to startup and the security context to “run whether the user is logged on or not,” then test by rebooting without logging in.

Does “run whether the user is logged on or not” need a stored password?

For a specific user account, yes: that mode stores the account’s credentials so the task can run in the background with no interactive session, which is what /RU <user> /RP <password> does on the command line. If the work doesn’t need that user’s profile, running as the built-in SYSTEM account (/RU SYSTEM) avoids storing a password entirely. Either way, the task no longer depends on anyone being logged in.

Share post:

Subscribe

Popular

More like this
Related

Can AI CLI Conversation History Leak Answers Into a Blind Test?

You use an AI command-line tool to grade or answer hundreds of questions, one fresh run each. Then you find out it keeps every conversation on disk, answer keys included. Is run 200 quietly reading run 199?

The Code Snippets 403 That Comes From Your Host’s Firewall, Not WordPress

You change a few lines in a snippet, press Save, and get "Could not update snippet. Request failed with status code 403". Press Save on the unchanged snippet and it works. Your login is fine. Something between you and WordPress is reading the code itself.

Why a Flaky Test Passes Alone and Fails When the Machine Is Busy

Run the test by itself and it passes, every time. Run the whole suite in parallel and it fails, but only some days, and its failure looks exactly like a real bug. In our case the code was fine. The test was waiting on a clock.

Why Multisite Subsite Registration Sends Visitors to the Main Site

You put a "create an account" link on one site of a WordPress multisite. Visitors who click it land on the main site, which either says "Registration has been disabled" or signs them up there instead.