Overview
The cron service provides:- Flexible scheduling - One-time, recurring, or cron-expression based
- Isolated execution - Each job runs in a dedicated session
- Delivery options - Announce results to channels or trigger webhooks
- Wake modes - Immediate or next-heartbeat execution
- Automatic retry - Failed jobs retry with exponential backoff
Architecture
Cron jobs are managed byCronService (src/cron/service.ts):
~/.simpleclaw/cron/jobs.json
Job Types
System Event Jobs
Trigger a system event (no agent turn):Agent Turn Jobs
Run agent with a message and deliver response:Schedule Formats
One-time (ISO timestamp)
Recurring interval
Cron expression
minute hour day month weekday
Examples:
0 9 * * 1-5- 9am weekdays*/15 * * * *- Every 15 minutes0 0 1 * *- First of month at midnight30 14 * * 0- Sundays at 2:30pm
Staggering
Prevent thundering herd at top-of-hour (src/cron/stagger.ts):Session Targets
Main Session
Runs in the main agent session (shared state with user interactions):Isolated Session
Runs in a dedicated session (clean slate per job):Wake Modes
Next Heartbeat
Waits for next agent activity before executing:Immediate (Now)
Executes immediately when due:Delivery Options
Control how job results are delivered:No delivery
Announce to channel
- Specific:
telegram,discord,slack,signal, etc. last- Send to last channel user interacted from
Webhook
Job State Tracking
Each job maintains execution state (src/cron/types.ts:88):Error Handling
Consecutive failures: Jobs with repeated errors get exponential backoff Schedule errors: Jobs with broken cron expressions auto-disable after threshold Delivery failures: Tracked separately from execution failuresUsage Examples
Daily reminder
Weekly report
One-time task
Background maintenance
CLI Operations
Programmatic API
Create job
List jobs
Update job
Manual trigger
Webhook Validation
Webhook URLs are validated before saving (src/cron/webhook-url.ts):Storage Format
Jobs are stored in~/.simpleclaw/cron/jobs.json:
Troubleshooting
Job not running? Check if enabled:API Reference
Key files insrc/cron/:
service.ts- Main CronService class (src/cron/service.ts:7)types.ts- Job types and interfaces (src/cron/types.ts:1)schedule.ts- Schedule parsing and calculationisolated-agent.ts- Isolated session executiondelivery.ts- Result delivery logicwebhook-url.ts- Webhook validation (src/cron/webhook-url.ts:5)