Cron Mastery
Rule #1: Heartbeats drift. Cron is precise.
This skill provides the definitive guide for managing time in OpenClaw 2026.2.15+. It solves the "I missed my reminder" problem by enforcing a strict separation between casual checks (heartbeat) and hard schedules (cron).
The Core Principle
| System | Behavior | Best For | Risk |
|---|
| Heartbeat | "I'll check in when I can" (e.g., every 30-60m) | Email checks, casual news summaries, low-priority polling. | Drift: A "remind me in 10m" task will fail if the heartbeat is 30m. |
| Cron |
"I will run at exactly X time" | Reminders ("in 5 mins"), daily reports, system maintenance. |
Clutter: Creates one-off jobs that need cleanup. |
1. Setting Reliable Reminders (2026.2.15+ Standard)
Rule: Never use act:wait or internal loops for long delays (>1 min). Use cron:add with a one-shot at schedule.
Precision & The "Scheduler Tick"
While Cron is precise, execution depends on the
Gateway Heartbeat (typically every 10-60s). A job set for
:00 seconds will fire on the first "tick" after that time. Expect up to ~30s of variance depending on your gateway config.
Modern One-Shot Reminder Pattern
Use this payload structure for "remind me in X minutes" tasks.
Key Features (v2026.2.15+):
- - Payload Choice: Use AgentTurn with Strict Instructions for push notifications (reminders that ping your phone). Use systemEvent only for silent logs or background state updates.
- Reliability:
nextRunAtMs corruption and "Add-then-Update" deadlocks are resolved. - Auto-Cleanup: One-shot jobs auto-delete after success (
deleteAfterRun: true).
CRITICAL: Push Notifications vs. Silent Logs
- - systemEvent (Silent): Injects text into the chat history. Great for background logs, but WILL NOT ping the user's phone on Telegram/WhatsApp.
- AgentTurn (Proactive): Wakes an agent to deliver the message. REQUIRED for push notifications. Use the "Strict" prompt to avoid AI chatter.
For push-notification reminders (Reliable):
CODEBLOCK0
For background logs (Silent):
CODEBLOCK1
Cron Concurrency Rule (Stabilized)
Pre-2026.2.15, the "Add-then-Update" pattern caused deadlocks. While this is now stabilized, it is still
best practice to pass all parameters (including
wakeMode: "now") directly in the initial
cron.add call for maximum efficiency.
2. The Janitor (Auto-Cleanup) - LEGACY
Note: As of v2026.2.14, OpenClaw includes maintenance recompute semantics. The gateway now automatically cleans up stuck jobs and repairs corrupted schedules.
Manual cleanup is only needed for:
- - One-shot jobs created with
deleteAfterRun: false. - Stale recurring jobs you no longer want.
Why use sessionTarget: "main"? (CRITICAL)
Sub-agents (
isolated) often have restricted tool policies and cannot call
gateway or delete other
cron jobs. For system maintenance like the Janitor,
always target the
main session via
systemEvent so the primary agent (with full tool access) performs the cleanup.
3. Reference: Timezone Lock
For cron to work, the agent must know its time.
- * Action: Add the user's timezone to
MEMORY.md. - Example: INLINECODE16
- Validation: If a user says "remind me at 9 PM," confirm: "9 PM Cairo time?" before scheduling.
4. The Self-Wake Rule (Behavioral)
Problem: If you say "I'll wait 30 seconds" and end your turn, you go to sleep. You cannot wake up without an event.
Solution: If you need to "wait" across turns, you MUST schedule a Cron job.
- * Wait < 1 minute (interactive): Only allowed if you keep the tool loop open (using
act:wait). - Wait > 1 minute (async): Use Cron with
wakeMode: "now".
5. Legacy Migration Guide
If you have old cron jobs using these patterns, update them:
| Legacy (Pre-2026.2.3) | Modern (2026.2.15+) |
|---|
| INLINECODE19 | INLINECODE20 |
| INLINECODE21 in payload |
Not needed -
announce mode handles delivery |
|
"sessionTarget": "main" |
"sessionTarget": "isolated" (default behavior) |
| Manual ghost cleanup required | One-shots auto-delete (
deleteAfterRun: true) |
|
cron.update after
cron.add | Single-step
cron.add with all properties |
Troubleshooting
- * "My reminder didn't fire": Check
cron:list. Verify the at timestamp is in the future (ISO 8601 format). Ensure wakeMode: "now" is set. - "Gateway Timeout (10000ms)": This happens if the
cron tool takes too long (huge job list or file lock).
-
Fix 1: Manually delete
~/.openclaw/state/cron/jobs.json and restart the gateway if it's corrupted.
-
Fix 2: Run a manual sweep to reduce the job count.
- * "Job ran but I didn't get the message": Ensure you are using the Strict Instruction Pattern with
agentTurn + announce mode for proactive pings. - "The reminder message has extra commentary": The subagent is being conversational. Use the strict prompt pattern: INLINECODE36
Cron 精通指南
规则 #1:心跳会漂移。Cron 是精确的。
本技能提供了在 OpenClaw 2026.2.15+ 中管理时间的权威指南。它通过强制区分随意检查(心跳)和硬性计划(cron)来解决“我错过了提醒”的问题。
核心原则
| 系统 | 行为 | 最佳用途 | 风险 |
|---|
| 心跳 | “我方便时检查”(例如,每 30-60 分钟) | 邮件检查、随意新闻摘要、低优先级轮询。 | 漂移: 如果心跳间隔为 30 分钟,则“10 分钟后提醒我”的任务将失败。 |
| Cron |
“我将在确切时间 X 运行” | 提醒(“5 分钟后”)、每日报告、系统维护。 |
杂乱: 创建需要清理的一次性任务。 |
1. 设置可靠的提醒(2026.2.15+ 标准)
规则: 切勿使用 act:wait 或内部循环进行长时间延迟(>1 分钟)。请使用带有一次性 at 计划的 cron:add。
精度与“调度器滴答”
虽然 Cron 是精确的,但执行取决于
网关心跳(通常每 10-60 秒)。设置为 :00 秒的任务将在该时间之后的第一个“滴答”触发。根据网关配置,预计会有最多约 30 秒的偏差。
现代一次性提醒模式
对于“X 分钟后提醒我”的任务,请使用此有效载荷结构。
关键特性(v2026.2.15+):
- - 有效载荷选择: 对于推送通知(会 ping 您手机的提醒),请使用带有严格指令的 AgentTurn。仅对静默日志或后台状态更新使用 systemEvent。
- 可靠性: nextRunAtMs 损坏和“添加后更新”死锁问题已解决。
- 自动清理: 一次性任务在成功后自动删除(deleteAfterRun: true)。
关键:推送通知 vs. 静默日志
- - systemEvent(静默): 将文本注入聊天历史。非常适合后台日志,但不会在 Telegram/WhatsApp 上 ping 用户手机。
- AgentTurn(主动): 唤醒一个代理来传递消息。推送通知必需。使用“严格”提示以避免 AI 闲聊。
用于推送通知提醒(可靠):
json
{
name: 提醒:喝水,
schedule: { kind: at, at: 2026-02-06T01:30:00Z },
payload: {
kind: agentTurn,
message: 请将此确切消息原封不动地发送给用户,无需修改或评论:\n\n💧 喝水,Momo!
},
sessionTarget: isolated,
delivery: { mode: announce, channel: telegram, to: 1027899060 }
}
用于后台日志(静默):
json
{
name: 日志:系统脉冲,
schedule: { kind: every, everyMs: 3600000 },
payload: {
kind: systemEvent,
text: [脉冲] 系统健康。
},
sessionTarget: main
}
Cron 并发规则(已稳定)
在 2026.2.15 之前,“添加后更新”模式会导致死锁。虽然现在已稳定,但
最佳实践仍然是将所有参数(包括 wakeMode: now)直接传递给初始的 cron.add 调用,以实现最大效率。
2. 清洁工(自动清理)- 旧版
注意: 从 v2026.2.14 开始,OpenClaw 包含维护重新计算语义。网关现在会自动清理卡住的任务并修复损坏的计划。
仅在以下情况下需要手动清理:
- - 使用 deleteAfterRun: false 创建的一次性任务。
- 您不再需要的过时重复任务。
为什么要使用 sessionTarget: main?(关键)
子代理(isolated)通常具有受限的工具策略,无法调用 gateway 或删除其他 cron 任务。对于像清洁工这样的系统维护,
始终通过 systemEvent 定位 main 会话,以便主代理(具有完整工具访问权限)执行清理。
3. 参考:时区锁定
为了使 cron 正常工作,代理必须知道其时间。
- * 操作: 将用户的时区添加到 MEMORY.md。
- 示例: 时区:开罗 (GMT+2)
- 验证: 如果用户说“晚上 9 点提醒我”,请在安排前确认:“开罗时间晚上 9 点?”
4. 自唤醒规则(行为)
问题: 如果您说“我等 30 秒”然后结束您的回合,您将进入休眠状态。没有事件您无法唤醒。
解决方案: 如果您需要在回合之间“等待”,您必须安排一个 Cron 任务。
- * 等待 < 1 分钟(交互式): 仅当您保持工具循环打开(使用 act:wait)时才允许。
- 等待 > 1 分钟(异步): 使用带有 wakeMode: now 的 Cron。
5. 旧版迁移指南
如果您有使用这些模式的旧 cron 任务,请更新它们:
| 旧版(2026.2.3 之前) | 现代版(2026.2.15+) |
|---|
| schedule: {kind: at, atMs: 1234567890} | schedule: {kind: at, at: 2026-02-06T01:30:00Z} |
| 有效载荷中的 deliver: true |
不需要 - announce 模式处理投递 |
| sessionTarget: main | sessionTarget: isolated(默认行为) |
| 需要手动清理幽灵任务 | 一次性任务自动删除(deleteAfterRun: true) |
| cron.add 后的 cron.update | 单步 cron.add 包含所有属性 |
故障排除
- * “我的提醒没有触发”: 检查 cron:list。验证 at 时间戳是否在未来(ISO 8601 格式)。确保设置了 wakeMode: now。
- “网关超时 (10000ms)”: 如果 cron 工具耗时过长(任务列表庞大或文件锁定),则会发生此情况。
-
修复 1: 手动删除 ~/.openclaw/state/cron/jobs.json,如果已损坏,请重启网关。
-
修复 2: 运行手动清理以减少任务数量。
- * “任务已运行,但我没有收到消息”: 确保您对主动 ping 使用了带有 agentTurn + announce 模式的严格指令模式。
- “提醒消息有额外评论”: 子代理正在对话。请使用严格提示模式:请将此确切消息原封不动地发送给用户,无需修改或评论:\n\n💧 您的消息在此