[BUG] Claude Desktop scheduled-tasks runner leaves orphan CLI subprocesses

Resolved 💬 3 comments Opened May 12, 2026 by tony-sprintai Closed May 15, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Bug Report: Claude Desktop scheduled-tasks runner leaves orphan CLI subprocesses

Product: Claude Desktop (with Claude Code scheduled-tasks feature)
Version: claude-code 2.1.128
Platform: macOS
Severity: High (memory leak over time, GB-scale on power users)

Summary

The Claude Desktop scheduled-tasks runner spawns claude --output-format CLI subprocesses (plus Helpers/disclaimer and bun run helpers) for each scheduled task execution, but does not terminate these processes when the task completes. Over hours and days, orphan processes accumulate and consume 1–3 GB of memory.

Actual behavior

  • 50–75+ claude --output-format subprocesses accumulate, each consuming ~200 MB resident memory
  • Equal number of Helpers/disclaimer helpers accumulate (small but counted)
  • Equal number of bun run --cwd helpers accumulate
  • Oldest orphans observed running for >24 hours despite their associated scheduled task running for seconds or minutes
  • Total memory consumption from orphans: 1.6–3 GB
  • Process count is roughly proportional to (number of active tasks × hours since last restart)

Evidence

On a user's setup (Tony Lantz, Sprint AI) with 24 enabled recurring tasks:

Date: 2026-05-07 (after ~14 hours uptime)
- 38 orphan `claude --output-format` processes
- 21 orphan `Helpers/disclaimer` processes
- 16 orphan `bun run` processes
- Total: 75 orphan processes, 1.6 GB memory
- Oldest orphan: etime 14h 39min (single task instance, never terminated)

Date: 2026-05-10 (after ~48 hours uptime)
- 22 claude CLI orphans, 13 disclaimer, 11 bun = 46 orphans
- Equivalent memory load returned despite intermediate restart

After pkill -9 of all matching processes >30 min old: memory dropped from 13.51 GB used → 10.59 GB used (-3 GB), no impact on currently-running tasks or active Claude sessions.

Workaround attempted (and why it fails)

User created a scheduled cleanup task (orphan-cleanup) that runs pkill on processes older than 60 min. This worked initially but also killed user's own active long-running interactive Claude sessions because both orphan zombies and active user sessions appear identical in ps output (same command-line, same parent reparenting). The user lost two active work sessions ("Talar AI med Henrik 6 maj" and "Review AI support setup with Maria"). This means user-space workarounds cannot safely solve the problem — the runner itself must clean up.

Suggested fix

The scheduled-tasks runner should:

  1. Track PIDs of subprocesses it spawns
  2. Send SIGTERM (then SIGKILL after grace period) to those PIDs when the task's execution completes or times out
  3. Optionally: register an atexit handler in the spawned claude CLI to ensure self-termination when its parent task finishes

Impact

  • Power users with many scheduled tasks see their machine's memory exhausted within 1–2 days
  • Daily restarts of Claude Desktop become a forced workaround
  • Memory pressure affects all other apps on the machine
  • User-space cleanup is unsafe (can kill active sessions)

Contact

If more diagnostic data is needed (process tree dumps, scheduled-task configurations, lsof output), happy to provide.

What Should Happen?

Expected behavior

Each scheduled task spawns subprocesses that terminate cleanly when the task finishes. Total claude-related process count should stay roughly stable (only currently-running tasks + Claude Desktop itself).

Error Messages/Logs

## Evidence

On a user's setup (Tony Lantz, Sprint AI) with 24 enabled recurring tasks:


Date: 2026-05-07 (after ~14 hours uptime)
- 38 orphan `claude --output-format` processes
- 21 orphan `Helpers/disclaimer` processes
- 16 orphan `bun run` processes
- Total: 75 orphan processes, 1.6 GB memory
- Oldest orphan: etime 14h 39min (single task instance, never terminated)

Date: 2026-05-10 (after ~48 hours uptime)
- 22 claude CLI orphans, 13 disclaimer, 11 bun = 46 orphans
- Equivalent memory load returned despite intermediate restart


After `pkill -9` of all matching processes >30 min old: memory dropped from 13.51 GB used → 10.59 GB used (-3 GB), no impact on currently-running tasks or active Claude sessions.

Steps to Reproduce

Steps to reproduce

  1. Configure multiple recurring scheduled tasks (e.g., 15–25 tasks across various frequencies — daily, weekday, hourly variants)
  2. Let the system run for 24–72 hours without restarting Claude Desktop
  3. Open Activity Monitor and filter for claude

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

claude-code 2.1.128

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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