claude-code - 💡(How to fix) Fix [BUG] Claude Code Cron Bug: Deleted cron jobs continue firing in infinite loop [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#49198Fetched 2026-04-17 08:48:07
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Cron jobs created via CronCreate fire continuously in a rapid loop (every few seconds) instead of at their scheduled time. After deletion via CronDelete, the jobs continue firing indefinitely within the same session. The only workaround is to restart the Claude Code session.

Error Message

Error Messages/Logs

Root Cause

Cron jobs created via CronCreate fire continuously in a rapid loop (every few seconds) instead of at their scheduled time. After deletion via CronDelete, the jobs continue firing indefinitely within the same session. The only workaround is to restart the Claude Code session.

Fix Action

Workaround

  1. Delete the cron jobs via CronDelete
  2. Restart the Claude Code session (/quit and reopen)
  3. Recreate the cron jobs in the new session

Code Example

CronCreate: cron="57 8 * * 1-5" prompt="/my-custom-skill" durable=true recurring=true
   CronCreate: cron="27 16 * * 1-5" prompt="/my-custom-skill" durable=true recurring=true

---

CronDelete: id="<job-id-1>"
   CronDelete: id="<job-id-2>"

---

CronList"No scheduled jobs."

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

Claude Code Cron Bug: Deleted cron jobs continue firing in infinite loop

Summary

Cron jobs created via CronCreate fire continuously in a rapid loop (every few seconds) instead of at their scheduled time. After deletion via CronDelete, the jobs continue firing indefinitely within the same session. The only workaround is to restart the Claude Code session.

Environment

  • Claude Code version: <= 2.1.92
  • Platform: macOS Darwin 23.5.0
  • Shell: zsh
  • Model: Claude Opus 4.6 (1M context)
  • Interface: Claude Code CLI (VS Code extension)

Steps to Reproduce

  1. Create two recurring durable cron jobs:

    CronCreate: cron="57 8 * * 1-5" prompt="/my-custom-skill" durable=true recurring=true
    CronCreate: cron="27 16 * * 1-5" prompt="/my-custom-skill" durable=true recurring=true

    These are scheduled for weekdays at 8:57 AM and 4:27 PM.

  2. Leave the session open. The jobs begin firing correctly at first.

  3. Over time (observed over multiple days, April 6-13), the jobs start firing continuously in a rapid loop — every few seconds — instead of once at the scheduled time.

  4. The skill /my-custom-skill was invoked dozens of times within minutes, all for the same time slot, with no pause between invocations.

  5. Attempt to stop by deleting both jobs:

    CronDelete: id="<job-id-1>"
    CronDelete: id="<job-id-2>"

    Both return Cancelled job <id>.

  6. Verify deletion:

    CronList → "No scheduled jobs."

    Also confirmed .claude/scheduled_tasks.json contains {"tasks": []}.

  7. Jobs continue firing despite deletion and empty task list. The skill kept being invoked repeatedly.

Expected Behavior

  • Cron jobs should fire once at each scheduled time (8:57 AM and 4:27 PM on weekdays)
  • After CronDelete, jobs should immediately stop firing
  • No queued invocations should persist after deletion

Actual Behavior

  • Jobs fire continuously in a rapid loop (every few seconds, not at scheduled intervals)
  • After CronDelete + confirmation of empty task list, jobs continue firing indefinitely
  • Over 100+ invocations occurred in a single session for the same time slot
  • The only way to stop the loop was to restart the Claude Code session (/quit)

Impact

  • Context window exhaustion: Each invocation consumes context, eventually forcing conversation compaction
  • Unusable session: The user cannot interact with Claude normally while the loop is running — every response is interrupted by another cron invocation
  • No way to stop: Deletion via CronDelete does not stop the loop within the current session
  • Resource waste: Dozens of redundant API calls to external services (in this case, mitigated by caching the result)

Timeline

DateObservation
April 6, 2026Cron jobs created (two durable recurring jobs)
April 6-12Jobs appeared to fire correctly (reports generated for each day)
April 13Jobs began firing in rapid loop — dozens of invocations within minutes
April 13Both jobs deleted via CronDelete, confirmed empty
April 13Jobs continued firing despite deletion — 100+ invocations total
April 13Session restart required to stop the loop
April 14No morning report was generated (jobs were deleted, no session running)

Workaround

  1. Delete the cron jobs via CronDelete
  2. Restart the Claude Code session (/quit and reopen)
  3. Recreate the cron jobs in the new session

Additional Notes

  • The cron jobs were created as durable: true and persisted to .claude/scheduled_tasks.json
  • The skill being invoked is a custom read-only orchestrator that calls external APIs — the bug is entirely in the cron scheduler, not the skill
  • The rapid-fire loop suggests the scheduler is not tracking "last fired" state and re-evaluates the cron expression on every tick, finding it still matches and firing again immediately
  • The post-deletion persistence suggests fired events are queued in-memory and the queue is not flushed on delete

What Should Happen?

Expected Behavior

  • Cron jobs should fire once at each scheduled time (8:57 AM and 4:27 PM on weekdays)
  • After CronDelete, jobs should immediately stop firing
  • No queued invocations should persist after deletion

Error Messages/Logs

Steps to Reproduce

Expected Behavior

  • Cron jobs should fire once at each scheduled time (8:57 AM and 4:27 PM on weekdays)
  • After CronDelete, jobs should immediately stop firing
  • No queued invocations should persist after deletion

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

<= 2.1.92

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The most likely fix for the cron job issue is to restart the Claude Code session after deleting the jobs, as the current session seems to cache the job invocations and does not stop them even after deletion.

Guidance

  • Verify cron job deletion: After deleting the cron jobs using CronDelete, confirm that the .claude/scheduled_tasks.json file is updated and empty.
  • Restart the session: Restart the Claude Code session by using the /quit command and reopening it to ensure that any cached job invocations are cleared.
  • Recreate cron jobs: Recreate the cron jobs in the new session to ensure they are properly scheduled and fired at the intended times.
  • Monitor job behavior: Closely monitor the behavior of the recreated cron jobs to ensure they fire as expected and do not enter a rapid loop.
  • Check for updates: Keep an eye on updates for the Claude Code version, as this issue may be addressed in a future release.

Example

No specific code example is provided, as the issue seems to be related to the internal workings of the Claude Code cron job scheduler rather than a code snippet that can be modified.

Notes

The provided information suggests that the issue is specific to the Claude Code version (<= 2.1.92) and may be related to how the cron job scheduler handles job deletions and cached invocations. The workaround of restarting the session after job deletion seems to be the most reliable way to stop the rapid loop of job invocations.

Recommendation

Apply the workaround of restarting the Claude Code session after deleting the cron jobs, as it is the most straightforward way to address the issue given the current version of Claude Code. This approach ensures that any cached job invocations are cleared, and the session is reset to a clean state.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING