Scheduled task agent processes never exit after completion (macOS)

Resolved 💬 3 comments Opened Mar 31, 2026 by Weiktseng Closed Apr 3, 2026

Bug Description

Scheduled task agents spawned by Claude Desktop never terminate after completing their work. Each cron trigger spawns a new claude process that remains alive indefinitely, causing unbounded memory growth.

Environment

  • OS: macOS 14.5 (Darwin 23.5.0)
  • Claude Desktop: latest (as of 2026-03-31)
  • Claude Code: 2.1.78

Steps to Reproduce

  1. Create a scheduled task with */30 * * * * cron (every 30 minutes)
  2. The task prompt is simple: read a few files, report status (read-only, no side effects)
  3. Wait several hours

Expected Behavior

Each scheduled task agent should exit cleanly after completing its prompt (producing output and finishing all tool calls).

Actual Behavior

Every triggered agent process stays alive after completion. Over 24 hours with 3 scheduled tasks at */30 intervals:

  • ~114 zombie claude processes accumulated
  • Each process ~170MB RSS → ~17GB total RAM consumed
  • System swap exhausted, Finder became unresponsive
  • Processes are all children of Claude.app/Contents/Helpers/disclaimer (local agent mode)
  • All running with --output-format stream-json --allow-dangerously-skip-permissions
$ ps aux | grep "claude.*--output-format" | grep -v grep | wc -l
114

Process start times show the exact cron pattern — new batch every 30 minutes, old ones never cleaned up:

6 processes started at 3/30 14:32
6 processes started at 3/30 15:02
6 processes started at 3/30 15:32
... (continues for 24+ hours)
6 processes started at 3/31 13:59

Additional Context

  • The scheduled tasks themselves were purely read-only monitors (read files, check ps, report status). They completed correctly — just never exited.
  • The loop/automation being monitored had already stopped normally days prior. The monitors kept spawning anyway (as expected from cron), but the completed agent processes accumulated.
  • Related: #39922 (Windows MCP server process zombies) — this is the macOS equivalent but for the agent process itself, not MCP servers.
  • No documentation warns about this behavior or process lifecycle management for scheduled tasks.

Impact

  • High — unattended scheduled tasks will eventually consume all system memory
  • Users may not realize background processes are accumulating since there's no visibility in the Claude Desktop UI
  • kill is the only remediation; no graceful cleanup mechanism exists

View original on GitHub ↗

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