Skip to content

How Does OpenClaw Heartbeat and Cron Automation Work?

I installed OpenClaw expecting it to proactively handle tasks—monitoring my systems, sending reminders, maybe even brewing my coffee (okay, not that last one). Instead, I found myself staring at a chat interface that did absolutely nothing until I messaged it.

That’s when I realized: OpenClaw isn’t a smart assistant out of the box. It’s a framework that provides the infrastructure for autonomous behavior, but you have to tell it when to act and what to do.

Let me walk you through how I cracked the automation puzzle with cron jobs and the HEARTBEAT.md system.

The Automation Desert

After my initial OpenClaw installation, I had this vision of waking up to a morning briefing delivered to my phone. I wanted reminders about meetings, alerts when services went down, and automated report generation.

What I got instead: silence. Complete, frustrating silence.

The root cause was simple—OpenClaw has no default automation. It’s reactive by design, waiting for you to prompt it. For users like me who expected an AI that takes initiative, this was a major letdown.

Two Paths to Automation

OpenClaw offers two distinct mechanisms for autonomous behavior:

  1. Standard Cron Jobs: Execute predefined prompts at specific times
  2. Heartbeat: A special cron job that reads instructions from a file

Let’s break down both approaches.

Path 1: Standard Cron Jobs

Cron jobs are time-based task triggers. You define when something should happen and what should happen when it does.

Here’s the basic idea:

Cron Job Concept
┌─────────────────────────────────────────┐
│ You define: │
│ - WHEN: Schedule (cron syntax) │
│ - WHAT: Prompt/instruction to execute │
│ │
│ OpenClaw executes: │
│ - At the scheduled time │
│ - With the predefined prompt │
│ - Without any manual intervention │
└─────────────────────────────────────────┘

Understanding Cron Syntax

The cron syntax might look intimidating at first:

Cron Syntax Breakdown
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6)
│ │ │ │ │ (Sunday = 0 or 7)
│ │ │ │ │
* * * * *

Let me show you some common patterns I use:

Common Cron Patterns
Pattern | Meaning | Use Case
-----------------|--------------------------|---------------------------
0 8 * * * | Every day at 8:00 AM | Morning briefing
0 8 * * 1-5 | Weekdays at 8:00 AM | Work reports
*/15 * * * * | Every 15 minutes | Frequent monitoring
0 */2 * * * | Every 2 hours | Periodic checks
0 9 * * 1 | Every Monday at 9 AM | Weekly summary
0 0 1 * * | First day of month | Monthly reports

My Morning Briefing Setup

I wanted a daily briefing at 8 AM. Here’s how I set it up:

Setting up a cron job via OpenClaw CLI
# The prompt I gave OpenClaw:
"Create a cron job that runs every day at 8 AM. When it runs,
you should:
1. Check my calendar for today's events
2. Review any urgent emails from overnight
3. Check the status of my monitored services
4. Generate a briefing and send it to my Telegram"
# OpenClaw created this cron entry internally:
# 0 8 * * * /path/to/openclaw --run-prompt "morning-briefing"

The beautiful part? Once configured, I never had to prompt OpenClaw again. It just worked.

Path 2: Heartbeat (HEARTBEAT.md)

While cron jobs are perfect for predictable, fixed-schedule tasks, what if you want more flexibility? What if you want to change what OpenClaw does without recreating cron jobs every time?

Enter Heartbeat.

Heartbeat is a special cron job that:

  • Runs on a fixed interval (default: 15-30 minutes)
  • Reads the HEARTBEAT.md file in your workspace
  • Executes whatever instructions are in that file
Heartbeat vs Regular Cron
Regular Cron Job:
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Schedule │───▶│ Fixed │───▶│ Execution │
│ (8 AM) │ │ Prompt │ │ (once) │
└──────────────┘ └──────────────┘ └──────────────┘
(defined at creation)
Heartbeat:
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Interval │───▶│ HEARTBEAT. │───▶│ Execution │
│ (every 15m) │ │ md file │ │ (repeated) │
└──────────────┘ └──────────────┘ └──────────────┘
(edit anytime!)

Creating My First HEARTBEAT.md

I started simple:

HEARTBEAT.md
# Heartbeat Instructions
## Every Heartbeat Run
1. Check for urgent emails in the last 30 minutes
2. If any calendar events start within the next hour, prepare a reminder
3. Monitor the status of critical services
4. If any monitored service is down, send Telegram alert

Every 15 minutes, OpenClaw reads this file and executes the instructions. If I want to add a new task, I just edit the file—no need to touch cron configurations.

Evolving My Heartbeat Setup

After a few weeks, my HEARTBEAT.md grew more sophisticated:

HEARTBEAT.md (evolved)
# Heartbeat Instructions
## Every Heartbeat Run (every 15 minutes)
### Email Monitoring
1. Check for emails marked "urgent" or "critical"
2. If found, summarize and send immediate alert
### Calendar Awareness
1. Check for events starting within 60 minutes
2. Prepare context-aware reminder (include location, attendees)
### Service Health
1. Ping critical services (my blog, database, API endpoints)
2. If any service fails health check:
- Log the failure with timestamp
- Send Telegram notification with service name
- Attempt basic diagnostics
## Time-Based Conditional Actions
### Morning Routine (6 AM - 10 AM)
- Summarize overnight activity (emails, errors, mentions)
- Check weather forecast for the day
- Generate todo list suggestions
### Afternoon Check (2 PM - 3 PM)
- Review progress on tracked tasks
- Check for approaching deadlines
### Evening Routine (6 PM - 8 PM)
- Prepare end-of-day summary
- Check tomorrow's calendar for early meetings
- Generate report of completed tasks
## Error Handling
If any instruction fails:
1. Log the error with full context
2. Continue with remaining instructions
3. Send summary of failures at end of heartbeat

When to Use Which Approach?

After months of experimentation, here’s my decision framework:

Decision Matrix
Use Regular Cron Jobs When:
✓ Task has a specific, predictable schedule
✓ The prompt/action is unlikely to change
✓ You want one-time setup and forget
Examples:
- Daily morning briefing at 8 AM
- Weekly report generation on Mondays
- Monthly cleanup tasks
Use Heartbeat When:
✓ Task needs to run frequently (monitoring, checking)
✓ Instructions may evolve over time
✓ You want multi-step workflows with conditionals
✓ You're still experimenting with what to automate
Examples:
- Service health monitoring
- Email filtering and alerting
- Context-aware reminders based on time of day

Common Mistakes I Made (So You Don’t Have To)

Mistake 1: Expecting Autonomous Behavior Without Setup

I spent my first week wondering why OpenClaw wasn’t doing anything. Then I read the documentation and realized—you have to create the automation.

Wrong vs Right Approach
WRONG: Install OpenClaw → Wait for magic → Nothing happens
RIGHT: Install OpenClaw → Set up cron jobs → Create HEARTBEAT.md → Enjoy automation

Mistake 2: Overly Complex Initial Heartbeat

My first HEARTBEAT.md was 200 lines long with nested conditionals, API calls to services I didn’t have yet, and logic that assumed perfect conditions.

It failed spectacularly.

Heartbeat Evolution
Version 1 (too complex):
- 50+ conditional branches
- Assumed all services existed
- No error handling
Version 2 (refined):
- 10 clear instructions
- Added service existence checks
- Graceful failure handling
Lesson: Start with 3-5 simple instructions, iterate from there

Mistake 3: Setting Heartbeat Interval Too Short

I set my heartbeat to run every 1 minute, thinking “more frequent = better.”

Result: API rate limits, overlapping executions, and a very confused OpenClaw instance.

The default 15-30 minute interval exists for a reason. Most tasks don’t need second-by-second monitoring.

Mistake 4: No Error Handling in HEARTBEAT.md

When something failed in my heartbeat instructions, the entire execution stopped. I’d miss alerts because step 1 failed and step 2 never ran.

Error handling pattern
# BAD: No error handling
1. Fetch data from API
2. Process the data
3. Send notification
# GOOD: Graceful degradation
1. Fetch data from API
- If fails: Log error, use cached data, continue
2. Process the data
- If fails: Log error, skip to next instruction
3. Send notification
- If fails: Retry once, then log for manual review

Real-World Automation Ideas

Once I got the hang of it, here are some automations that actually made my life better:

My Current Automation Stack
Daily (8 AM):
├── Morning briefing (calendar, urgent emails, weather)
├── News digest from configured sources
└── Task prioritization suggestions
Every 15 minutes (Heartbeat):
├── Service health monitoring (blog, APIs, databases)
├── Email filtering for urgent items
├── Calendar reminder preparation
└── Error log monitoring
Weekly (Monday 9 AM):
├── Review of previous week's tasks
├── Metrics dashboard update
└── Blog post idea generation
Monthly (1st of month):
├── Generate monthly report
├── Archive old logs
└── Backup verification

The real unlock, as one Reddit user put it: “Setting up cron jobs so it actually does stuff without me messaging it.”

That’s the key insight—OpenClaw is a powerful framework, but its power is dormant until you configure the triggers.

Technical Deep Dive: How It Works Under the Hood

If you’re curious about the implementation:

Automation Flow Architecture
┌─────────────────────────────────────────────────────────────┐
│ Cron Daemon (system level) │
│ ├── Standard cron job │
│ │ └── At scheduled time → Trigger OpenClaw with prompt │
│ │ │
│ └── Heartbeat cron job │
│ └── Every N minutes → OpenClaw reads HEARTBEAT.md │
│ → Parse instructions │
│ → Execute each instruction sequentially │
│ → Handle errors and log results │
└─────────────────────────────────────────────────────────────┘
Key Components:
1. Cron Scheduler: System-level time trigger
2. Prompt Registry: Stores predefined prompts for cron jobs
3. HEARTBEAT.md Parser: Reads and interprets heartbeat instructions
4. Execution Engine: Runs the instructions with proper context
5. Notification System: Sends results to configured channels

If you’re diving deeper into OpenClaw automation, these concepts will help:

  1. Cron Expressions: Master cron syntax for precise scheduling
  2. Markdown as Code: Understanding how HEARTBEAT.md becomes executable logic
  3. Idempotent Operations: Design tasks that can safely run multiple times
  4. Error Recovery: Graceful handling when APIs fail or services are down
  5. Rate Limiting: Understanding API limits to avoid being blocked

Summary

OpenClaw’s automation works through two complementary mechanisms:

AspectRegular Cron JobsHeartbeat
TriggerFixed scheduleFixed interval (15-30 min)
InstructionsDefined at creationRead from HEARTBEAT.md
FlexibilityRequires recreation to changeEdit file to change
Best ForSpecific, predictable tasksOngoing monitoring, multi-task workflows

The bottom line: OpenClaw won’t do anything autonomously until you configure it. But once you set up cron jobs and create a thoughtful HEARTBEAT.md, it transforms from a passive chat interface into an active AI assistant that works while you sleep.

Start simple. Add complexity gradually. And remember—the 15-minute heartbeat interval is that long for a reason.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments