Scheduled tasks leak headless claude.exe --resume processes on Windows (never exit, accumulate until OOM)

Open 💬 3 comments Opened Jun 15, 2026 by khenderson-asurity

Summary

On Windows, a recurring scheduled task (created via Claude Code's scheduled-tasks feature) spawns a headless claude.exe --resume <id> --output-format stream-json worker on every fire. The worker finishes its work but never exits — it sits idle indefinitely. Over hours these accumulate until the machine runs out of RAM and freezes (hard reboot required). Still reproduces on 2.1.170.

This looks related to #58565 (closed as duplicate) and #42169 / #54130 (both closed "not planned"), but the trigger here is different — a scheduled task on a timer, not closing a session window or opening the panel — and it still happens, so filing fresh with current details.

Environment

  • Claude Code 2.1.170 (channel latest; embedded in Claude Desktop, no standalone CLI)
  • Claude Desktop 1.12603.1.0
  • Windows 11 Pro
  • Several MCP servers configured (Slack, Atlassian, Bitbucket, Postman, …)

Repro

  1. Create a recurring scheduled task (~7-minute cron) that runs a trivial step and stops (e.g. a watcher task that just runs a script via Bash).
  2. Leave it running for several hours.
  3. Watch the claude.exe process count and total memory climb.

Expected

Each scheduled run's headless process exits when the run completes.

Actual

Each run leaves a resident claude.exe --resume … --output-format stream-json --input-format stream-json --permission-prompt-tool stdio process:

  • ~95 orphaned workers accumulated over ~10 hours (one per ~7-min fire).
  • ~250–430 MB each; ~36 GB total across all claude.exe before the machine OOM'd and froze.
  • Each worker burned ~3–5 min of CPU (it did run the work) then sat at ~0% CPU forever — finished, then hung instead of exiting.
  • All parented to the Claude Desktop supervisor process.
  • Separately, 2,322 local_*.json session files (~622 MB) piled up under %APPDATA%\Claude\claude-code-sessions\… over ~3 weeks, never pruned.

Likely cause

The headless --resume worker blocks waiting for a stdin EOF the launcher never sends (no idle timeout in headless mode), so it never terminates. The configured MCP servers loaded on each run also keep connections/handles open, inflating each worker's footprint.

Impact

System-wide memory exhaustion → laptop freezes → hard reboot. It's silent (no UI), so it's easy to miss until the machine locks up.

Workaround

Disable the scheduled task and reap the orphans:

Get-CimInstance Win32_Process -Filter "Name='claude.exe'" |
  Where-Object { $_.CommandLine -like '*claude-code*--output-format stream*' -and ((Get-Date)-$_.CreationDate).TotalMinutes -gt 10 } |
  Stop-Process -Force

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗