自动化
约 392 字大约 1 分钟
定时任务
定时执行任务。
概述
Cron 任务在 Gateway 内运行,可以:
- 按计划执行
- 发送系统事件
- 发送消息
添加任务
## 每小时运行
openclaw cron add --name "hourly-check" --every 1h --system-event "检查状态"
## Cron 表达式(每天 9 点)
openclaw cron add --name "daily-report" --cron "0 9 * * *" --message "生成日报"
## 指定时间运行一次
openclaw cron add --name "one-time" --at "2024-12-31T23:59:00" --message "新年快乐"管理任务
## 列出任务
openclaw cron list
## 查看状态
openclaw cron status
## 启用/禁用
openclaw cron enable id>
openclaw cron disable id>
## 编辑
openclaw cron edit id> --every 2h
## 删除
openclaw cron rm id>
## 手动运行
openclaw cron run id> --force
## 查看运行历史
openclaw cron runs --id <id> --limit 10Cron 表达式
标准 5 字段 cron 格式:
分 时 日 月 周示例:
0 9 * * *- 每天 9:00*/30 * * * *- 每 30 分钟0 0 * * 0- 每周日 0:00
时区
指定时区:
openclaw cron add --name "task" --cron "0 9 * * *" --tz "Asia/Shanghai" --message "早安"注意事项
- Cron 在 Gateway 进程内运行
- Gateway 必须持续运行
- 任务错过不会补执行
Webhook
接收外部事件。
概述
Webhook 允许外部系统触发 OpenClaw 动作。
配置
{
"webhooks": {
"enabled": true,
"endpoints": [
{
"path": "/webhook/my-hook",
"secret": "webhook-secret",
"action": "system-event"
}
]
}使用
发送 POST 请求:
curl -X POST http://localhost:18789/webhook/my-hook \
-H "X-Webhook-Secret: webhook-secret" \
-H "Content-Type: application/json" \验证
使用 secret 验证请求来源:
{
"secret": "your-webhook-secret"请求头:X-Webhook-Secret: your-webhook-secret
动作类型
system-event- 触发系统事件message- 发送消息agent- 触发智能体
Gmail Pub/Sub
Gmail 集成使用 Google Cloud Pub/Sub:
openclaw webhooks gmail setup --account your@gmail.com