claude-code - 💡(How to fix) Fix [BUG] Claude Desktop scheduled-tasks runner leaves orphan CLI subprocesses

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 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.

Error Message

Error Messages/Logs

Root Cause

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.

Fix Action

Fix / Workaround

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.

  • 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)

Code Example

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

---

## 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.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

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…

FAQ

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).

Still need to ship something?

×6

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

Back to top recommendations

TRENDING