You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add command-backed cron jobs with timeout-safe process-tree cleanup for shell wrappers. Ensures POSIX command jobs run in a killable process group, adds Windows tree cleanup fallback handling, and covers timeout cleanup behind sh -lc.
Copy file name to clipboardExpand all lines: docs/automation/cron-jobs.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,33 @@ This fires ~5–6 times per month instead of 0–1 times per month. OpenClaw use
122
122
</Accordion>
123
123
</AccordionGroup>
124
124
125
+
### Command payloads
126
+
127
+
Use command payloads for deterministic scripts that should run inside the Gateway scheduler without starting a model-backed isolated agent turn. Command jobs execute on the Gateway host, capture stdout/stderr, record the run in cron history, and reuse the same `announce`, `webhook`, and `none` delivery modes as isolated jobs.
128
+
129
+
<Note>
130
+
Command cron is an operator-admin Gateway automation surface, not an agent
131
+
`tools.exec` call. Creating, updating, removing, or manually running cron jobs
132
+
requires `operator.admin`; scheduled command runs later execute inside the
133
+
Gateway process as that admin-authored automation. Agent exec policy such as
134
+
`tools.exec.mode`, approval prompts, and per-agent tool allowlists governs
135
+
model-visible exec tools, not command cron payloads.
136
+
</Note>
137
+
138
+
```bash
139
+
openclaw cron create "*/15 * * * *" \
140
+
--name "Queue depth probe" \
141
+
--command "scripts/check-queue.sh" \
142
+
--command-cwd "/srv/app" \
143
+
--announce \
144
+
--channel telegram \
145
+
--to "-1001234567890"
146
+
```
147
+
148
+
`--command <shell>` stores `argv: ["sh", "-lc", <shell>]`. Use `--command-argv '["node","scripts/report.mjs"]'` when you want exact argv execution without shell parsing. Optional `--command-env KEY=VALUE`, `--command-input`, `--timeout-seconds`, `--no-output-timeout-seconds`, and `--output-max-bytes` fields control the process environment, stdin, and output bounds.
149
+
150
+
If stdout is non-empty, that text is the delivered result. If stdout is empty and stderr is non-empty, stderr is delivered. If both streams are present, cron delivers a small `stdout:` / `stderr:` block. A zero exit code records the run as `ok`; non-zero exit, signal, timeout, or no-output timeout records `error` and can trigger failure alerts. A command that prints only `NO_REPLY` uses the normal cron silent-token suppression and posts nothing back to chat.
151
+
125
152
### Payload options for isolated jobs
126
153
127
154
<ParamFieldpath="--message"type="string"required>
@@ -246,6 +273,17 @@ Failure notifications follow a separate destination path:
Use `--command` for deterministic shell-style jobs that should run inside OpenClaw cron without starting an isolated agent/model run:
38
+
39
+
<Note>
40
+
Command cron jobs are admin-authored Gateway automation. Creating, editing,
41
+
removing, or manually running them requires `operator.admin`; the scheduled run
42
+
later executes in the Gateway process, not as an agent `tools.exec` tool call.
43
+
`tools.exec.*` and exec approvals still govern model-visible exec tools.
44
+
</Note>
45
+
46
+
```bash
47
+
openclaw cron create "*/15 * * * *" \
48
+
--name "Queue depth probe" \
49
+
--command "scripts/check-queue.sh" \
50
+
--command-cwd "/srv/app" \
51
+
--announce \
52
+
--channel telegram \
53
+
--to "-1001234567890"
54
+
```
55
+
56
+
`--command <shell>` stores `argv: ["sh", "-lc", <shell>]`. Use `--command-argv '["node","scripts/report.mjs"]'` for exact argv execution. Command jobs capture stdout/stderr, record normal cron history, and route output through the same `announce`, `webhook`, or `none` delivery modes as isolated jobs. A command that prints only `NO_REPLY` is suppressed.
57
+
37
58
## Sessions
38
59
39
60
`--session` accepts `main`, `isolated`, `current`, or `session:<id>`.
@@ -92,6 +113,10 @@ Note: isolated cron runs treat run-level agent failures as job errors even when
92
113
no reply payload is produced, so model/provider failures still increment error
93
114
counters and trigger failure notifications.
94
115
116
+
Command cron jobs do not start an isolated agent turn. A zero exit code records
117
+
`ok`; non-zero exit, signal, timeout, or no-output timeout records `error` and
118
+
can trigger the same failure notification path.
119
+
95
120
If an isolated run times out before the first model request, `openclaw cron show`
96
121
and `openclaw cron runs` include a phase-specific error such as
`--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.
254
279
280
+
Create a command job with exact argv, cwd, env, stdin, and output limits:
0 commit comments