ClawSkills logoClawSkills

Casual Cron

使用严格的运行守卫规则从自然语言创建 Clawdbot cron 任务。当:用户要求安排提醒或消息(重复或一次性),尤其是

介绍

# Casual Cron

使用自然语言为 Clawdbot 创建定时任务。支持一次性任务和重复任务,并提供安全的运行守卫规则。

## Cron 运行守卫(硬性规则)

- 在定时任务内部运行时:不要进行故障排查,不要重启网关,不要检查时间。 - 不要发送确认或解释。 - 仅输出确切的消息负载,然后停止。

---

## 工作原理

1. 智能体从用户消息(或 `/at` / `/every` 命令)中检测调度意图。 2. 解析:时间、频率、频道、目的地、消息。 3. 使用正确的标志构建 `openclaw cron add` 命令。 4. 在执行前与用户确认解析的时间、任务名称和任务 ID。

---

## 调度规则

当消息以 `/at` 或 `/every` 开头时,通过 CLI 进行调度(而非 cron 工具 API)。

使用:`openclaw cron add`

### /at(一次性)

- 如果用户给出时钟时间(例如 "3pm"),请转换为 ISO 格式,并根据该日期的 America/New_York 计算偏移量(感知 DST)。 - 对于短期提醒,优先使用相对时间(例如 `--at "20m"`)。 - 使用 `--session isolated --message "Output exactly: <task>"`。 - 始终包含 `--delete-after-run`。 - 始终包含 `--deliver --channel <channel> --to <destination>`。

### /every(重复)

- 如果是时间间隔:使用 `--every "<duration>"`(无需时区)。 - 如果是时钟时间:使用 `--cron "<expr>" --tz "America/New_York"`。 - 使用 `--session isolated --message "Output exactly: <task>"`。 - 始终包含 `--deliver --channel <channel> --to <destination>`。

### 确认

- 在最终确定之前,始终与用户确认解析的时间、任务名称和任务 ID。

---

## 命令参考

一次性(时钟时间,感知 DST): ``` openclaw cron add \ --name "Reminder example" \ --at "2026-01-28T15:00:00-05:00" \ --session isolated \ --message "Output exactly: <TASK>" \ --deliver --channel telegram --to <TELEGRAM_CHAT_ID> \ --delete-after-run ```

一次性(相对时间): ``` openclaw cron add \ --name "Reminder in 20m" \ --at "20m" \ --session isolated \ --message "Output exactly: <TASK>" \ --deliver --channel telegram --to <TELEGRAM_CHAT_ID> \ --delete-after-run ```

重复(时钟时间,感知 DST): ``` openclaw cron add \ --name "Daily 3pm reminder" \ --cron "0 15 * * *" --tz "America/New_York" \ --session isolated \ --message "Output exactly: <TASK>" \ --deliver --channel telegram --to <TELEGRAM_CHAT_ID> ```

重复(时间间隔): ``` openclaw cron add \ --name "Every 2 hours" \ --every "2h" \ --session isolated \ --message "Output exactly: <TASK>" \ --deliver --channel telegram --to <TELEGRAM_CHAT_ID> ```

---

## 配置

| 设置 | 值 | |---------|-------| | 默认时区 | `America/New_York` (感知 DST) | | 默认频道 | `telegram` (可通过 `CRON_DEFAULT_CHANNEL` 环境变量覆盖) | | 支持的频道 | telegram, whatsapp, slack, discord, signal |

---

## 支持的模式

### 时间格式

| 输入 | Cron | |-------|------| | `8am` | `0 8 * * *` | | `8:45pm` | `45 20 * * *` | | `noon` | `0 12 * * *` | | `midnight` | `0 0 * * *` | | `14:30` | `30 14 * * *` |

### 频率

| 输入 | 行为 | |-------|----------| | `daily` / `every day` | 每天在指定时间 | | `weekdays` / `mon-fri` | 周一至周五在指定时间 | | `mondays` / `every monday` | 每周一 | | `hourly` / `every hour` | 每小时的 :00 分 | | `every 2 hours` | `0 */2 * * *` | | `weekly` | 每周(默认为周一) | | `monthly` | 每月(每月 1 号) |

更多产品