mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 18:17:27 +00:00
feat(cron): add default stagger controls for scheduled jobs
This commit is contained in:
@@ -115,11 +115,22 @@ Cron supports three schedule kinds:
|
||||
|
||||
- `at`: one-shot timestamp via `schedule.at` (ISO 8601).
|
||||
- `every`: fixed interval (ms).
|
||||
- `cron`: 5-field cron expression with optional IANA timezone.
|
||||
- `cron`: 5-field cron expression (or 6-field with seconds) with optional IANA timezone.
|
||||
|
||||
Cron expressions use `croner`. If a timezone is omitted, the Gateway host’s
|
||||
local timezone is used.
|
||||
|
||||
To reduce top-of-hour load spikes across many gateways, OpenClaw applies a
|
||||
deterministic per-job stagger window of up to 5 minutes for recurring
|
||||
top-of-hour expressions (for example `0 * * * *`, `0 */2 * * *`). Fixed-hour
|
||||
expressions such as `0 7 * * *` remain exact.
|
||||
|
||||
For any cron schedule, you can set an explicit stagger window with `schedule.staggerMs`
|
||||
(`0` keeps exact timing). CLI shortcuts:
|
||||
|
||||
- `--stagger 30s` (or `1m`, `5m`) to set an explicit stagger window.
|
||||
- `--exact` to force `staggerMs = 0`.
|
||||
|
||||
### Main vs isolated execution
|
||||
|
||||
#### Main session jobs (system events)
|
||||
@@ -408,6 +419,19 @@ openclaw cron add \
|
||||
--to "+15551234567"
|
||||
```
|
||||
|
||||
Recurring cron job with explicit 30-second stagger:
|
||||
|
||||
```bash
|
||||
openclaw cron add \
|
||||
--name "Minute watcher" \
|
||||
--cron "0 * * * * *" \
|
||||
--tz "UTC" \
|
||||
--stagger 30s \
|
||||
--session isolated \
|
||||
--message "Run minute watcher checks." \
|
||||
--announce
|
||||
```
|
||||
|
||||
Recurring isolated job (deliver to a Telegram topic):
|
||||
|
||||
```bash
|
||||
@@ -465,6 +489,12 @@ openclaw cron edit <jobId> \
|
||||
--thinking low
|
||||
```
|
||||
|
||||
Force an existing cron job to run exactly on schedule (no stagger):
|
||||
|
||||
```bash
|
||||
openclaw cron edit <jobId> --exact
|
||||
```
|
||||
|
||||
Run history:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -74,7 +74,9 @@ See [Heartbeat](/gateway/heartbeat) for full configuration.
|
||||
|
||||
## Cron: Precise Scheduling
|
||||
|
||||
Cron jobs run at **exact times** and can run in isolated sessions without affecting main context.
|
||||
Cron jobs run at precise times and can run in isolated sessions without affecting main context.
|
||||
Recurring top-of-hour schedules are automatically spread by a deterministic
|
||||
per-job offset in a 0-5 minute window.
|
||||
|
||||
### When to use cron
|
||||
|
||||
@@ -87,7 +89,9 @@ Cron jobs run at **exact times** and can run in isolated sessions without affect
|
||||
|
||||
### Cron advantages
|
||||
|
||||
- **Exact timing**: 5-field cron expressions with timezone support.
|
||||
- **Precise timing**: 5-field or 6-field (seconds) cron expressions with timezone support.
|
||||
- **Built-in load spreading**: recurring top-of-hour schedules are staggered by up to 5 minutes by default.
|
||||
- **Per-job control**: override stagger with `--stagger <duration>` or force exact timing with `--exact`.
|
||||
- **Session isolation**: Runs in `cron:<jobId>` without polluting main history.
|
||||
- **Model overrides**: Use a cheaper or more powerful model per job.
|
||||
- **Delivery control**: Isolated jobs default to `announce` (summary); choose `none` as needed.
|
||||
|
||||
Reference in New Issue
Block a user