























@@ -2,100 +2,142 @@
22summary: "CLI reference for `openclaw cron` (schedule and run background jobs)"
33read_when:
44 - You want scheduled jobs and wakeups
5- - You’re debugging cron execution and logs
5+ - You are debugging cron execution and logs
66title: "Cron"
77---
8899# `openclaw cron`
10101111Manage cron jobs for the Gateway scheduler.
121213-Related:
13+<Tip>
14+Run `openclaw cron --help` for the full command surface. See [Cron jobs](/automation/cron-jobs) for the conceptual guide.
15+</Tip>
141615-- Cron jobs: [Cron jobs](/automation/cron-jobs)
17+## Sessions
161817-Tip: run `openclaw cron --help` for the full command surface.
19+`--session` accepts `main`, `isolated`, `current`, or `session:<id>`.
182019-Note: `openclaw cron list` and `openclaw cron show <job-id>` preview the
20-resolved delivery route. For `channel: "last"`, the preview shows whether the
21-route resolved from the main/current session or will fail closed.
21+<AccordionGroup>
22+<Accordion title="Session keys">
23+- `main` binds to the agent's main session.
24+- `isolated` creates a fresh transcript and session id for each run.
25+- `current` binds to the active session at creation time.
26+- `session:<id>` pins to an explicit persistent session key.
27+</Accordion>
28+<Accordion title="Isolated session semantics">
29+Isolated runs reset ambient conversation context. Channel and group routing, send/queue policy, elevation, origin, and ACP runtime binding are reset for the new run. Safe preferences and explicit user-selected model or auth overrides can carry across runs.
30+</Accordion>
31+</AccordionGroup>
223223-Note: isolated `cron add` jobs default to `--announce` delivery. Use `--no-deliver` to keep
24-output internal. `--deliver` remains as a deprecated alias for `--announce`.
33+## Delivery
253426-Note: isolated cron chat delivery is shared. `--announce` is runner fallback
27-delivery for the final reply; `--no-deliver` disables that fallback but does
28-not remove the agent's `message` tool when a chat route is available.
35+`openclaw cron list` and `openclaw cron show <job-id>` preview the resolved delivery route. For `channel: "last"`, the preview shows whether the route resolved from the main or current session, or will fail closed.
293630-Note: one-shot (`--at`) jobs delete after success by default. Use `--keep-after-run` to keep them.
37+<Note>
38+Isolated `cron add` jobs default to `--announce` delivery. Use `--no-deliver` to keep output internal. `--deliver` remains as a deprecated alias for `--announce`.
39+</Note>
314032-Note: `--session` supports `main`, `isolated`, `current`, and `session:<id>`.
33-Use `current` to bind to the active session at creation time, or `session:<id>` for
34-an explicit persistent session key.
41+### Delivery ownership
354236-Note: `--session isolated` creates a fresh transcript/session id for each run.
37-Safe preferences and explicit user-selected model/auth overrides can carry, but
38-ambient conversation context does not: channel/group routing, send/queue policy,
39-elevation, origin, and ACP runtime binding are reset for the new isolated run.
43+Isolated cron chat delivery is shared between the agent and the runner:
404441-Note: for one-shot CLI jobs, offset-less `--at` datetimes are treated as UTC unless you also pass
42-`--tz <iana>`, which interprets that local wall-clock time in the given timezone.
45+- The agent can send directly using the `message` tool when a chat route is available.
46+- `announce` fallback-delivers the final reply only when the agent did not send directly to the resolved target.
47+- `webhook` posts the finished payload to a URL.
48+- `none` disables runner fallback delivery.
434944-Note: recurring jobs now use exponential retry backoff after consecutive errors (30s → 1m → 5m → 15m → 60m), then return to normal schedule after the next successful run.
50+`--announce` is runner fallback delivery for the final reply. `--no-deliver` disables that fallback but does not remove the agent's `message` tool when a chat route is available.
455146-Note: `openclaw cron run` now returns as soon as the manual run is queued for execution. Successful responses include `{ ok: true, enqueued: true, runId }`; use `openclaw cron runs --id <job-id>` to follow the eventual outcome.
52+Reminders created from an active chat preserve the live chat delivery target for fallback announce delivery. Internal session keys may be lowercase; do not use them as a source of truth for case-sensitive provider IDs such as Matrix room IDs.
475348-Note: `openclaw cron run <job-id>` force-runs by default. Use `--due` to keep the
49-older "only run if due" behavior.
54+### Failure delivery
505551-Note: isolated cron turns suppress stale acknowledgement-only replies. If the
52-first result is just an interim status update and no descendant subagent run is
53-responsible for the eventual answer, cron re-prompts once for the real result
54-before delivery.
56+Failure notifications resolve in this order:
555756-Note: if an isolated cron run returns only the silent token (`NO_REPLY` /
57-`no_reply`), cron suppresses direct outbound delivery and the fallback queued
58-summary path as well, so nothing is posted back to chat.
58+1. `delivery.failureDestination` on the job.
59+2. Global `cron.failureDestination`.
60+3. The job's primary announce target (when no explicit failure destination is set).
596160-Note: isolated cron runs prefer structured execution-denial metadata from the
61-embedded run, then fall back to known denial markers in final output, such as
62-`SYSTEM_RUN_DENIED`, `INVALID_REQUEST`, and approval-binding refusal phrases.
63-`cron list` and run history surface the denial reason instead of reporting a
64-blocked command as `ok`.
62+<Note>
63+Main-session jobs may only use `delivery.failureDestination` when primary delivery mode is `webhook`. Isolated jobs accept it in all modes.
64+</Note>
656566-Note: `cron add|edit --model ...` uses that selected allowed model for the job.
67-If the model is not allowed, cron warns and falls back to the job's agent/default
68-model selection instead. Configured fallback chains still apply, but a plain
69-model override with no explicit per-job fallback list no longer appends the
70-agent primary as a hidden extra retry target.
66+## Scheduling
716772-Note: isolated cron model precedence is Gmail-hook override first, then per-job
73-`--model`, then any user-selected stored cron-session model override, then the
74-normal agent/default selection.
68+### One-shot jobs
756976-Note: isolated cron fast mode follows the resolved live model selection. Model
77-config `params.fastMode` applies by default, but a stored session `fastMode`
78-override still wins over config.
70+`--at <datetime>` schedules a one-shot run. Offset-less datetimes are treated as UTC unless you also pass `--tz <iana>`, which interprets the wall-clock time in the given timezone.
797180-Note: if an isolated run throws `LiveSessionModelSwitchError`, cron persists the
81-switched provider/model (and switched auth profile override when present) for
82-the active run before retrying. The outer retry loop is bounded to 2 switch
83-retries after the initial attempt, then aborts instead of looping forever.
72+<Note>
73+One-shot jobs delete after success by default. Use `--keep-after-run` to preserve them.
74+</Note>
847585-Note: failure notifications use `delivery.failureDestination` first, then
86-global `cron.failureDestination`, and finally fall back to the job's primary
87-announce target when no explicit failure destination is configured.
76+### Recurring jobs
887789-Note: retention/pruning is controlled in config:
78+Recurring jobs use exponential retry backoff after consecutive errors: 30s, 1m, 5m, 15m, 60m. The schedule returns to normal after the next successful run.
79+80+### Manual runs
81+82+`openclaw cron run` returns as soon as the manual run is queued. Successful responses include `{ ok: true, enqueued: true, runId }`. Use `openclaw cron runs --id <job-id>` to follow the eventual outcome.
83+84+<Note>
85+`openclaw cron run <job-id>` force-runs by default. Use `--due` to keep the older "only run if due" behavior.
86+</Note>
87+88+## Models
89+90+`cron add|edit --model <ref>` selects an allowed model for the job.
91+92+<Warning>
93+If the model is not allowed, cron warns and falls back to the job's agent or default model selection. Configured fallback chains still apply, but a plain model override with no explicit per-job fallback list no longer appends the agent primary as a hidden extra retry target.
94+</Warning>
95+96+### Isolated cron model precedence
97+98+Isolated cron resolves the active model in this order:
99+100+1. Gmail-hook override.
101+2. Per-job `--model`.
102+3. Stored cron-session model override (when the user selected one).
103+4. Agent or default model selection.
104+105+### Fast mode
106+107+Isolated cron fast mode follows the resolved live model selection. Model config `params.fastMode` applies by default, but a stored session `fastMode` override still wins over config.
108+109+### Live model switch retries
110+111+If an isolated run throws `LiveSessionModelSwitchError`, cron persists the switched provider and model (and switched auth profile override when present) for the active run before retrying. The outer retry loop is bounded to two switch retries after the initial attempt, then aborts instead of looping forever.
112+113+## Run output and denials
114+115+### Stale acknowledgement suppression
116+117+Isolated cron turns suppress stale acknowledgement-only replies. If the first result is just an interim status update and no descendant subagent run is responsible for the eventual answer, cron re-prompts once for the real result before delivery.
118+119+### Silent token suppression
120+121+If an isolated cron run returns only the silent token (`NO_REPLY` or `no_reply`), cron suppresses both direct outbound delivery and the fallback queued summary path, so nothing is posted back to chat.
122+123+### Structured denials
124+125+Isolated cron runs prefer structured execution-denial metadata from the embedded run, then fall back to known denial markers in final output, such as `SYSTEM_RUN_DENIED`, `INVALID_REQUEST`, and approval-binding refusal phrases.
126+127+`cron list` and run history surface the denial reason instead of reporting a blocked command as `ok`.
128+129+## Retention
130+131+Retention and pruning are controlled in config:
9013291133- `cron.sessionRetention` (default `24h`) prunes completed isolated run sessions.
92-- `cron.runLog.maxBytes` + `cron.runLog.keepLines` prune `~/.openclaw/cron/runs/<jobId>.jsonl`.
134+- `cron.runLog.maxBytes` and `cron.runLog.keepLines` prune `~/.openclaw/cron/runs/<jobId>.jsonl`.
9313594-Upgrade note: if you have older cron jobs from before the current delivery/store format, run
95-`openclaw doctor --fix`. Doctor now normalizes legacy cron fields (`jobId`, `schedule.cron`,
96-top-level delivery fields including legacy `threadId`, payload `provider` delivery aliases) and migrates simple
97-`notify: true` webhook fallback jobs to explicit webhook delivery when `cron.webhook` is
98-configured.
136+## Migrating older jobs
137+138+<Note>
139+If you have cron jobs from before the current delivery and store format, run `openclaw doctor --fix`. Doctor normalizes legacy cron fields (`jobId`, `schedule.cron`, top-level delivery fields including legacy `threadId`, payload `provider` delivery aliases) and migrates simple `notify: true` webhook fallback jobs to explicit webhook delivery when `cron.webhook` is configured.
140+</Note>
99141100142## Common edits
101143@@ -137,21 +179,9 @@ openclaw cron add \
137179138180`--light-context` applies to isolated agent-turn jobs only. For cron runs, lightweight mode keeps bootstrap context empty instead of injecting the full workspace bootstrap set.
139181140-Delivery ownership note:
141-142-- Isolated cron chat delivery is shared. The agent can send directly with the
143-`message` tool when a chat route is available.
144-- `announce` fallback-delivers the final reply only when the agent did not send
145- directly to the resolved target. `webhook` posts the finished payload to a URL.
146-`none` disables runner fallback delivery.
147-- Reminders created from an active chat preserve the live chat delivery target
148- for fallback announce delivery. Internal session keys may be lowercase; do not
149- use them as a source of truth for case-sensitive provider IDs such as Matrix
150- room IDs.
151-152182## Common admin commands
153183154-Manual run:
184+Manual run and inspection:
155185156186```bash
157187openclaw cron list
@@ -161,10 +191,9 @@ openclaw cron run <job-id> --due
161191openclaw cron runs --id <job-id> --limit 50
162192```
163193164-`cron runs` entries include delivery diagnostics with the intended cron target,
165-the resolved target, message-tool sends, fallback use, and delivered state.
194+`cron runs` entries include delivery diagnostics with the intended cron target, the resolved target, message-tool sends, fallback use, and delivered state.
166195167-Agent/session retargeting:
196+Agent and session retargeting:
168197169198```bash
170199openclaw cron edit <job-id> --agent ops
@@ -182,14 +211,6 @@ openclaw cron edit <job-id> --no-best-effort-deliver
182211openclaw cron edit <job-id> --no-deliver
183212```
184213185-Failure-delivery note:
186-187-- `delivery.failureDestination` is supported for isolated jobs.
188-- Main-session jobs may only use `delivery.failureDestination` when primary
189- delivery mode is `webhook`.
190-- If you do not set any failure destination and the job already announces to a
191- channel, failure notifications reuse that same announce target.
192-193214## Related
194215195216- [CLI reference](/cli)
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。