Cron Job Setup
Our conventions for creating cron jobs in OpenClaw.
Default Settings
| Setting | Default | Why |
|---|
| Model | INLINECODE0 | Reliable tool calls, works with any Anthropic Max plan — no OpenRouter needed |
| Session |
isolated | Cron jobs run in their own session, not the main chat |
|
Delivery |
"mode": "none" | Job handles its own output (posts to Discord, etc.) |
|
Timeout | 120-180s | Most jobs should finish fast |
Model Notes
- - Default to Sonnet (
anthropic/claude-sonnet-4-5). Reliable, portable (no OpenRouter API key needed). - DeepSeek is unreliable for tool calls — don't use it for cron jobs.
- Use Opus (
anthropic/claude-opus-4-6) only as a last resort — expensive for scheduled tasks. - Model ID format: Use
anthropic/claude-sonnet-4-5 not the full dated version (anthropic/claude-sonnet-4-20250514).
Job Template
CODEBLOCK0
Schedule Patterns
| Pattern | Cron Expression | Notes |
|---|
| Every 30 min | INLINECODE7 | Good for inbox checks, monitoring |
| Every hour |
0 * * * * | Self-reflection, status checks |
| Daily at 4 AM |
0 4 * * * | Cleanup, backups (during quiet hours) |
| Daily at 6 AM |
0 6 * * * | Morning digests, daily summaries |
| Weekly Monday 2 PM |
0 14 * * 1 | Weekly outreach, reviews |
| One-shot | Use
"kind": "at" instead | Reminders, one-time tasks |
Task Instruction Conventions
- 1. Be explicit with commands — Give the cron agent exact bash commands to run. It doesn't have our context.
- Include skip conditions — If there's nothing to do, the agent should reply
SKIP to avoid wasting tokens. - Handle its own output — The job should post results to Telegram (or wherever) using the
message tool directly. Don't rely on delivery mode for formatted output. - Include error handling — What should happen if a command fails?
- Keep instructions self-contained — The cron agent wakes up with no context. Everything it needs should be in the task message.
Telegram Posting from Cron Jobs
When a cron job needs to notify us, include these instructions in the task:
CODEBLOCK1
Topic IDs:
- -
1 — Main topic (general updates, alerts) - INLINECODE16 — Research
- INLINECODE17 — Crypto
- INLINECODE18 — PR updates / dev notifications
- INLINECODE19 — Sticker store
- INLINECODE20 — Activity feed (workspace changes)
Delivery Modes
| Mode | When to Use |
|---|
| INLINECODE21 | Job posts its own output to Telegram (most common) |
| INLINECODE22 |
OpenClaw auto-delivers the agent's final message to a channel. Use when output IS the message (e.g., daily digest). Set
"channel": "telegram" and
"to": "-1003856094222:TOPIC_ID" |
Anti-Patterns
❌ Don't use Opus for cron jobs unless the task genuinely needs it. Most cron tasks are simple checks.
❌ Don't use heartbeat for things that can be a cron job. Heartbeat runs in the main session (Opus) and costs way more.
❌ Don't create cron jobs that loop/poll — each run should be a single check. If you need polling, use a background exec script instead.
❌ Don't set delivery mode to "announce" and also have the job post to Telegram — you'll get duplicate messages.
Existing Jobs (Reference)
Check current jobs anytime with the cron list tool. As of setup:
- -
workspace-activity-feed — Every 30 min, commits workspace changes, posts to activity feed - INLINECODE27 — Every 30 min, checks for new emails, responds to agents
- INLINECODE28 — Every 15 min, checks on stalled sub-agents
- INLINECODE29 — Hourly, reviews recent sessions for lessons learned
- INLINECODE30 — Daily 4 AM, git commits workspace changes
- INLINECODE31 — Daily 4 AM, checks system resources
- INLINECODE32 — Daily 6 AM, generates news digest
- INLINECODE33 — Weekly Monday 2 PM, agent outreach for sticker store
Cron 任务设置
我们在 OpenClaw 中创建 cron 任务的约定。
默认设置
| 设置项 | 默认值 | 原因 |
|---|
| 模型 | anthropic/claude-sonnet-4-5 | 可靠的工具调用,适用于任何 Anthropic Max 计划 — 无需 OpenRouter |
| 会话 |
isolated | Cron 任务在自己的会话中运行,而非主聊天 |
|
投递 | mode: none | 任务自行处理输出(发布到 Discord 等) |
|
超时 | 120-180秒 | 大多数任务应快速完成 |
模型说明
- - 默认使用 Sonnet (anthropic/claude-sonnet-4-5)。可靠、可移植(无需 OpenRouter API 密钥)。
- DeepSeek 不可靠 用于工具调用 — 不要将其用于 cron 任务。
- 使用 Opus (anthropic/claude-opus-4-6) 仅作为最后手段 — 对于定时任务来说成本较高。
- 模型 ID 格式: 使用 anthropic/claude-sonnet-4-5 而非完整日期版本(anthropic/claude-sonnet-4-20250514)。
任务模板
json
{
name: 描述性-短横线-命名,
schedule: {
kind: cron,
expr: /30 *,
tz: America/New_York
},
sessionTarget: isolated,
payload: {
kind: agentTurn,
message: 任务指令在此,
model: openrouter/deepseek/deepseek-v3.2,
timeoutSeconds: 120
},
delivery: {
mode: none
}
}
调度模式
| 模式 | Cron 表达式 | 说明 |
|---|
| 每30分钟 | /30 | 适用于收件箱检查、监控 |
| 每小时 |
0
* | 自我反思、状态检查 |
| 每天凌晨4点 | 0 4
* | 清理、备份(在安静时段) |
| 每天早上6点 | 0 6
* | 早间摘要、每日总结 |
| 每周一下午2点 | 0 14
1 | 每周外联、回顾 |
| 一次性 | 改用 kind: at | 提醒、一次性任务 |
任务指令约定
- 1. 明确给出命令 — 向 cron 代理提供确切的 bash 命令。它没有我们的上下文。
- 包含跳过条件 — 如果无事可做,代理应回复 SKIP 以避免浪费 token。
- 自行处理输出 — 任务应直接使用 message 工具将结果发布到 Telegram(或其他平台)。不要依赖投递模式进行格式化输出。
- 包含错误处理 — 如果命令失败应该怎么办?
- 保持指令自包含 — Cron 代理启动时没有上下文。它所需的一切都应包含在任务消息中。
从 Cron 任务发布到 Telegram
当 cron 任务需要通知我们时,在任务中包含以下指令:
使用消息工具发布到 Telegram:
- - action: send
- channel: telegram
- target: -1003856094222
- threadId: TOPIC_ID
- message: 您的格式化消息
主题 ID:
- - 1 — 主主题(一般更新、警报)
- 573 — 研究
- 1032 — 加密货币
- 1488 — PR 更新 / 开发通知
- 1869 — 贴纸商店
- 3188 — 活动动态(工作区变更)
投递模式
| 模式 | 使用时机 |
|---|
| mode: none | 任务自行将输出发布到 Telegram(最常见) |
| mode: announce |
OpenClaw 自动将代理的最终消息投递到频道。当输出本身就是消息时使用(例如每日摘要)。设置 channel: telegram 和 to: -1003856094222:TOPIC_ID |
反模式
❌ 不要为 cron 任务使用 Opus,除非任务确实需要。大多数 cron 任务都是简单的检查。
❌ 不要使用心跳 来处理可以用 cron 任务完成的事情。心跳在主会话(Opus)中运行,成本高得多。
❌ 不要创建循环/轮询的 cron 任务 — 每次运行应是一次性检查。如果需要轮询,请改用后台执行脚本。
❌ 不要同时设置投递模式为 announce 并让任务自行发布到 Telegram — 会导致重复消息。
现有任务(参考)
随时使用 cron list 工具查看当前任务。截至设置时:
- - workspace-activity-feed — 每30分钟,提交工作区变更,发布到活动动态
- agentmail-inbox-check — 每30分钟,检查新邮件,回复代理
- sub-agent-monitor — 每15分钟,检查停滞的子代理
- self-reflection — 每小时,回顾最近会话以总结经验
- daily-workspace-commit — 每天凌晨4点,git 提交工作区变更
- system-watchdog — 每天凌晨4点,检查系统资源
- OpenClaw Daily News Digest — 每天早上6点,生成新闻摘要
- sticker-sales-loop — 每周一下午2点,代理外联推广贴纸商店