openclaw - ✅(Solved) Fix Cron may keep stale in-memory schedule after job expression change, causing duplicate runs (sanitized) [1 pull requests, 3 comments, 3 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
openclaw/openclaw#71607Fetched 2026-04-26 05:10:44
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
0
Timeline (top)
commented ×3cross-referenced ×2mentioned ×2subscribed ×1

After migrating OpenClaw cron config from a single daily Instagram editorial job to split weekday/weekend jobs, the old daily schedule appears to have remained active in memory. On Saturday, April 25, 2026, the old daily job fired at 06:00 America/Sao_Paulo and the new weekend job fired at 07:00, causing two Telegram deliveries for the same editorial flow.

Root Cause

After migrating OpenClaw cron config from a single daily Instagram editorial job to split weekday/weekend jobs, the old daily schedule appears to have remained active in memory. On Saturday, April 25, 2026, the old daily job fired at 06:00 America/Sao_Paulo and the new weekend job fired at 07:00, causing two Telegram deliveries for the same editorial flow.

Fix Action

Fixed

PR fix notes

PR #71651: fix(cron): invalidate stale nextRun after schedule reload

Description (problem / solution / changelog)

fix(cron): invalidate stale nextRun after schedule reload

Summary

This fixes a cron reload drift bug where a job could still fire using a stale in-memory state.nextRunAtMs after its cron expression was changed on disk.

Fixes #71607.

Root Cause

  • Timer ticks reload jobs.json with forceReload: true and skipRecompute: true.
  • When a job's schedule expression changed, persisted state.nextRunAtMs could still carry a future timestamp computed for the old expression.
  • Maintenance recompute intentionally preserves existing future nextRunAtMs, so the stale timestamp could survive and trigger an unexpected run.

What Changed

  • Updated src/cron/service/store.ts:
    • compare reloaded jobs against the previous in-memory copy by id;
    • when scheduling inputs change (schedule or enabled), clear state.nextRunAtMs.
  • Added regression coverage in src/cron/service/store.test.ts:
    • verifies a forced reload with changed cron expr invalidates stale nextRunAtMs.

Validation

  • pnpm test src/cron/service/store.test.ts (pass)
  • pnpm check:changed (fails due to unrelated pre-existing repo-wide typecheck errors in other surfaces; touched cron test surface passes)

Risk / Follow-up

  • Risk is low and scoped to reload paths where scheduling inputs change.
  • Unchanged jobs keep existing behavior.

AI-assisted

  • AI-assisted and manually reviewed.

Changed files

  • CHANGELOG.md (modified, +3/-0)
  • docs/automation/cron-jobs.md (modified, +8/-0)
  • docs/cli/cron.md (modified, +5/-0)
  • src/cron/service/store.test.ts (modified, +196/-0)
  • src/cron/service/store.ts (modified, +46/-0)
RAW_BUFFERClick to expand / collapse

Summary

After migrating OpenClaw cron config from a single daily Instagram editorial job to split weekday/weekend jobs, the old daily schedule appears to have remained active in memory. On Saturday, April 25, 2026, the old daily job fired at 06:00 America/Sao_Paulo and the new weekend job fired at 07:00, causing two Telegram deliveries for the same editorial flow.

What I expected

Only the weekend job should have run on Saturday.

What happened

Two distinct cron jobs delivered to the same Telegram target on the same Saturday morning:

  • weekday job e246053c-2041-49b1-8d71-a00d75730503 ran at 2026-04-25 06:00:00 -03
  • weekend job 4cc17c47-c6a4-4a3d-a091-2bcf1cd55314 ran at 2026-04-25 07:00:00 -03

Deliveries arrived at:

  • 06:34:16 -03
  • 07:03:25 -03

This caused two Telegram messages for what should have been a single daily editorial delivery.

Current config

Current /home/gulp-digital/.openclaw/cron/jobs.json shows:

  • weekday job e246053c-2041-49b1-8d71-a00d75730503
    • 30 5 * * 1-5
  • weekend job 4cc17c47-c6a4-4a3d-a091-2bcf1cd55314
    • 30 6 * * 0,6

So the weekday job should not have fired on Saturday.

Historical evidence

I found older backups of the cron store:

jobs.json.bak

Shows the same main job id e246053c-2041-49b1-8d71-a00d75730503 previously configured as:

  • 0 1 * * *

and a retry job at:

  • 0 7 * * *

jobs.json.bak-2026-04-22-0912

Shows a later intermediate state where the same main job id e246053c-2041-49b1-8d71-a00d75730503 was configured as:

  • 0 6 * * *

At that point there was still no separate weekend job.

Why this looks like stale in-memory cron state

The observed Saturday run at 06:00 matches the older daily 06:00 schedule, not the current weekday-only schedule.

That suggests the gateway process that was alive overnight still had an older schedule loaded in memory, while the persisted cron store later reflected the newer split weekday/weekend config.

In other words, this does not look like cron parsing 1-5 incorrectly as including Saturday. It looks more like one of these:

  1. cron schedule mutation did not invalidate already loaded timers
  2. gateway needed an explicit reload/restart after editing cron jobs
  3. cron store update and active in-memory schedule diverged temporarily

Extra details

  • jobs.json mtime after the morning runs was 2026-04-25 07:03:25 -03
  • the gateway process currently running started only later at 2026-04-25 10:01:13 -03, so it was not the process that scheduled the 06:00 and 07:00 runs
  • I did not find evidence of a restart between 05:00 and 08:30, which further weakens the idea of a fresh cron parser bug and strengthens the stale loaded schedule hypothesis

Impact

This can produce duplicate external deliveries when a cron schedule is changed from one pattern to another but the old timer remains active.

Request

Please check whether cron job edits properly invalidate and reschedule in-memory timers, especially when:

  • an existing job id changes its cron expression
  • one daily job is split into weekday + weekend jobs
  • the gateway keeps running across that migration

It would also help if cron startup / reschedule logs included the effective loaded expression per job, so this kind of issue can be diagnosed more directly.

extent analysis

TL;DR

The most likely fix is to restart the gateway process after editing cron jobs to ensure that the new schedule is loaded into memory.

Guidance

  • Verify that the cron job edits properly invalidate and reschedule in-memory timers by checking the gateway process logs for evidence of a reload or restart after editing cron jobs.
  • Check the cron store update and active in-memory schedule for divergence, which may cause temporary issues like the one described.
  • Consider adding logging to the cron startup and reschedule processes to include the effective loaded expression per job, making it easier to diagnose similar issues in the future.
  • Test the scenario of splitting a daily job into weekday and weekend jobs to ensure that the gateway process correctly handles the change without requiring a manual restart.

Example

No code snippet is provided as the issue is related to the cron job scheduling and gateway process management, which does not require a specific code example.

Notes

The issue seems to be related to the gateway process not reloading the new cron schedule after editing the jobs, causing the old schedule to remain active in memory. The provided information suggests that a restart of the gateway process may resolve the issue, but further testing and logging are necessary to confirm.

Recommendation

Apply a workaround by restarting the gateway process after editing cron jobs to ensure that the new schedule is loaded into memory. This is recommended because the issue appears to be related to the gateway process not properly handling changes to the cron schedule, and a restart provides a straightforward way to ensure the new schedule is applied.

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

openclaw - ✅(Solved) Fix Cron may keep stale in-memory schedule after job expression change, causing duplicate runs (sanitized) [1 pull requests, 3 comments, 3 participants]