cron
管理计划任务(通过网关 RPC)。
用法
bash
openclaw cron <子命令> [选项]通用选项
所有 cron 命令接受:
--url: 网关 URL--token: 网关 token--timeout: 超时时间--expect-final: 期望最终响应
子命令
cron status
显示 cron 状态。
bash
openclaw cron status [--json]cron list
列出计划任务。
bash
openclaw cron list [--all] [--json]选项:
--all: 显示所有任务--json: JSON 输出(默认为表格)
cron add
添加计划任务。别名:create
bash
openclaw cron add [选项]必需:
--name: 任务名称- 以下之一:
--at、--every、--cron - 以下之一:
--system-event、--message
选项:
--at <time>: 指定时间运行--every <interval>: 间隔运行(如30m、1h)--cron <expression>: Cron 表达式--system-event <text>: 系统事件--message <text>: 消息--tz <timezone>: 时区
cron edit
编辑计划任务。
bash
openclaw cron edit <id> [选项]cron rm
删除计划任务。别名:remove、delete
bash
openclaw cron rm <id>cron enable
启用计划任务。
bash
openclaw cron enable <id>cron disable
禁用计划任务。
bash
openclaw cron disable <id>cron runs
查看任务运行历史。
bash
openclaw cron runs --id <id> [--limit <n>]cron run
手动运行任务。
bash
openclaw cron run <id> [--force]选项:
--force: 强制运行(即使已禁用)
示例
bash
# 查看 cron 状态
openclaw cron status
# 列出所有任务
openclaw cron list --all
# 添加每小时运行的任务
openclaw cron add --name "hourly-check" --every 1h --system-event "check status"
# 添加 cron 表达式任务(每天 9 点)
openclaw cron add --name "daily-report" --cron "0 9 * * *" --message "生成日报"
# 手动运行任务
openclaw cron run my-task-id --force
# 查看运行历史
openclaw cron runs --id my-task-id --limit 10
# 禁用任务
openclaw cron disable my-task-id注意事项
- Cron 在 Gateway 进程内运行
- 如果 Gateway 没有持续运行,计划任务不会执行
- 时区设置很重要,使用
--tz指定