-
-
Notifications
You must be signed in to change notification settings - Fork 54.6k
Description
Description
Cron jobs added via the cron tool while the gateway is running are persisted to storage but never execute. They remain in an "idle" state (enabled, but lastRun is null) until the gateway is manually restarted.
Environment
- OpenClaw Version: Latest (installed via npm)
- Platform: macOS (Darwin 25.2.0, arm64)
- Node: v22.21.0
Steps to Reproduce
- Start the gateway:
openclaw gateway start - Wait for it to stabilize
- Create a cron job via the agent or CLI:
{ "name": "test-job", "schedule": {"kind": "every", "everyMs": 60000}, "sessionTarget": "main", "payload": {"kind": "systemEvent", "text": "Hello"} } - Wait for the scheduled time to pass
- Check job status:
cron action=list
Expected Behavior
Job should execute at the scheduled time.
Actual Behavior
Job never executes. Status shows:
enabled: truelastRun: null(never ran)nextRunAtMsmay be in the past
Only after openclaw gateway restart does the job start executing.
Evidence
Five production jobs created Feb 4-5 all showed this pattern:
| Job Name | Created | Last Run | Status |
|---|---|---|---|
| signal-collection | Feb 4 | null | Never executed |
| content-factory-morning-topics | Feb 5 | null | Never executed |
| pipeline-trigger | Feb 5 | null | Never executed |
| content-factory-reaction-scanner | Feb 5 | null | Never executed |
| Supabase keepalive | Feb 5 | null | Never executed |
All jobs were enabled: true with valid schedules.
Root Cause Hypothesis
The cron scheduler loads jobs from storage only at startup. Jobs added afterward are written to persistent storage but not registered with the in-memory scheduler. The scheduler never polls storage for new jobs.
Suggested Fix
Option A (Hot reload):
- When
cron action=addsucceeds, emit an event that the scheduler listens to - Scheduler adds the new job to its in-memory schedule
Option B (Polling):
- Scheduler periodically compares in-memory jobs vs storage
- Syncs any differences
Option C (File watch):
- Watch the cron storage file for changes
- Reload when modified
Workaround
After adding new cron jobs, run:
openclaw gateway restartThis forces a full reload of all jobs from storage.
Impact
- Severity: High — affects anyone adding cron jobs dynamically via agent
- User experience: Jobs silently fail to run with no error message
- Discoverability: Hard to debug since jobs appear valid in listings