Cron vs Heartbeat: When to Use Each for Agent Automation

Two scheduling paradigms, different strengths. A practical guide to choosing between cron jobs and heartbeat checks for your automation needs.

Tags: cron, heartbeat, automation, scheduling

Category: tutorial

Frequently Asked Questions

What's the main difference between cron and heartbeat in OpenClaw?

Cron jobs run at exact times (like Unix cron) in isolated sessions — great for precise scheduling. Heartbeats are periodic check-ins within your main session that let the agent batch multiple tasks together and access recent conversation context.

Can I use both cron and heartbeat together?

Absolutely, and that's the recommended approach. Use heartbeats for batched periodic checks (email + calendar + weather) and cron for exact-time tasks (daily reports at 9 AM, weekly summaries on Monday). They complement each other well.

How do I set up a cron job in OpenClaw?

Use the cron tool with action 'add', specifying a schedule (cron expression, interval, or one-shot time) and a payload (systemEvent for main session or agentTurn for isolated execution). The agent can also create cron jobs on your behalf when you ask for reminders.

Will heartbeat checks waste my API credits?

Each heartbeat consumes a small amount of tokens — typically a few hundred for a quick check. If nothing needs attention, the agent replies HEARTBEAT_OK with minimal usage. You can control frequency in your config to balance responsiveness vs. cost.