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: 运行手动清理以减少任务数量。
- * 任务运行了但我没有收到消息: 确保你使用严格指令模式,配合 agentTurn + announce 模式进行主动推送。
- 提醒消息有额外评论: 子代理在闲聊。使用严格提示模式:将此确切消息传递给用户,不得修改或评论:\n\n💧 你的消息在这里