hermes - 💡(How to fix) Fix [Bug] Windows Scheduled Task defaults cause gateway crash every ~24-72h (ExecutionTimeLimit, battery settings)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The Windows Scheduled Task created by hermes gateway install uses bare schtasks /Create with minimal flags (/SC ONLOGON /RL LIMITED). This relies on Windows defaults that are hostile to a long-running gateway process, causing the gateway to die every ~24-72 hours and making cron jobs unreliable.

Root Cause

  • Gateway exit diagnostics showed it dying every ~24h with signal-initiated shutdown
  • Cron jobs scheduled for 4 AM were being missed because the gateway was in a restart gap
  • The ExecutionTimeLimit PT72H was the primary cause - Windows hard-terminating the process

Fix Action

Fix

Replace the bare schtasks /Create approach with either:

  1. COM interface (Schedule.Service) via win32com.client or PowerShell subprocess, or
  2. XML task registration via schtasks /Create /XML

The correct settings should be:

<Settings>
  <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
  <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
  <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
  <StartWhenAvailable>true</StartWhenAvailable>
  <WakeToRun>true</WakeToRun>
  <AllowHardTerminate>false</AllowHardTerminate>
  <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
</Settings>

Code Example

<Settings>
  <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
  <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
  <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
  <StartWhenAvailable>true</StartWhenAvailable>
  <WakeToRun>true</WakeToRun>
  <AllowHardTerminate>false</AllowHardTerminate>
  <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
</Settings>
RAW_BUFFERClick to expand / collapse

Summary

The Windows Scheduled Task created by hermes gateway install uses bare schtasks /Create with minimal flags (/SC ONLOGON /RL LIMITED). This relies on Windows defaults that are hostile to a long-running gateway process, causing the gateway to die every ~24-72 hours and making cron jobs unreliable.

Affected File

hermes_cli/gateway_windows.py — function _install_scheduled_task()

Problem

The bare schtasks approach cannot override most task scheduler settings. The defaults that kill the gateway:

SettingDefaultEffect
ExecutionTimeLimitPT72H (3 days)Windows hard-kills the gateway process after 72 hours
StopIfGoingOnBatteriestrueKills gateway when laptop switches to battery
DisallowStartIfOnBatteriestrueGateway wont start at all on battery power
StartWhenAvailablefalseMissed trigger runs (e.g. PC was asleep) are silently skipped
WakeToRunfalsePC wont wake from sleep for scheduled runs
AllowHardTerminatetrueWindows can force-kill the process at will
MultipleInstancesPolicyIgnoreNewSecond start attempt silently dropped

Evidence

  • Gateway exit diagnostics showed it dying every ~24h with signal-initiated shutdown
  • Cron jobs scheduled for 4 AM were being missed because the gateway was in a restart gap
  • The ExecutionTimeLimit PT72H was the primary cause - Windows hard-terminating the process

Fix

Replace the bare schtasks /Create approach with either:

  1. COM interface (Schedule.Service) via win32com.client or PowerShell subprocess, or
  2. XML task registration via schtasks /Create /XML

The correct settings should be:

<Settings>
  <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
  <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
  <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
  <StartWhenAvailable>true</StartWhenAvailable>
  <WakeToRun>true</WakeToRun>
  <AllowHardTerminate>false</AllowHardTerminate>
  <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
</Settings>

Workaround (manual, requires elevated PowerShell)

Delete and recreate the task via the COM interface with full XML definition. Important: Windows stubbornly resets ExecutionTimeLimit to PT72H on UPDATE operations. Only a full DELETE + CREATE via RegisterTask() with explicit PT0S in the XML worked.

Impact

  • Severity: High - makes cron jobs unreliable on Windows, gateway silently dies
  • Platform: Windows only
  • Component: hermes gateway install

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug] Windows Scheduled Task defaults cause gateway crash every ~24-72h (ExecutionTimeLimit, battery settings)