[BUG] Scheduled tasks leave orphaned Claude Code sessions running after completion

Resolved 💬 3 comments Opened Mar 21, 2026 by ahfeiathome Closed Mar 25, 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?

Each scheduled task run (created via create_scheduled_task) spawns a new Claude Code CLI process. When the task completes, the process is not terminated — it stays alive indefinitely. Over time, this accumulates many orphaned sessions consuming memory and CPU. These orphaned sessions also interfere with plugins (e.g., multiple sessions compete for Telegram bot polling, causing inbound messages to be consumed by a dead session).

What Should Happen?

When a scheduled task completes its run, the spawned Claude Code CLI process should cleanly exit and release all resources. Only the actively running task should have a live process.

Error Messages/Logs

No errors — processes silently remain alive. Observed via:

$ ps aux | grep claude
- Multiple claude processes with --model default running from previous scheduled task executions
- Each has its own PID and was spawned at different times matching the cron schedule
- Only one is the current active session; the rest are orphaned
- Orphaned sessions also hold plugin connections (e.g., Telegram polling), causing message delivery conflicts

Steps to Reproduce

  1. Enable scheduled tasks in Claude Desktop (coworkScheduledTasksEnabled: true)
  2. Create a scheduled task via create_scheduled_task with a short interval (e.g., /5 *)
  3. Let it run a few cycles
  4. Run: ps aux | grep claude
  5. Observe multiple Claude Code CLI processes still running from previous task runs
  6. These processes are idle but never exit

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

N/A — behavior appears to have existed since scheduled tasks were introduced

Claude Code Version

2.1.78

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Claude Code should have a /file-bug skill that auto-files to the GitHub repo. That itself is a feature request worth filing.

View original on GitHub ↗

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