The Heartbeat & Cron System
Like giving your agent a Fitbit — it checks in even when you don't
Right now, your agent sits there doing absolutely nothing until you type something. That's like hiring an employee and telling them "only work when I'm watching you." Let's fix that. This chapter turns your reactive chatbot into a proactive operator that works 24/7.
Two Ways to Make Your Agent Proactive
Cron is like an alarm clock. 6 AM: wake up. 8 AM: morning briefing. 2 AM: clean up. Exact times, specific tasks, no deviation. ⏰
- • Runs every ~30 minutes
- • Checks inbox, calendar, notifications
- • Batches multiple checks together
- • Stays quiet if nothing's happening
- • Has full conversation context
- • Like a watchful assistant
- • Runs at exact times you set
- • One specific task per job
- • Clean, isolated session each time
- • Can use different AI models
- • No conversation context needed
- • Like an automated employee
When to Use Which
This is the question everyone asks, so let's make it crystal clear:
- • Multiple checks can batch together (inbox + calendar + notifications)
- • You need recent conversation context
- • Exact timing doesn't matter (every ~30 min is fine)
- • You want to reduce API calls by combining periodic tasks
- • Exact timing matters ("every day at 6 AM sharp")
- • Task needs a clean, isolated session (no conversational baggage)
- • You want a different model for this task (e.g., cheaper model for routine work)
- • Output goes directly to a channel without needing main session
- • One-shot reminders ("remind me in 20 minutes")
Setting Up Heartbeat
The heartbeat system is controlled by a simple file called HEARTBEAT.md. Your agent reads this file every ~30 minutes and performs whatever checks are listed:
# Heartbeat Checklist ## Every Check (~30 min) - [ ] Any urgent unread emails? - [ ] Any mentions/DMs on Twitter? - [ ] Any calendar events in next 2 hours? ## 2-4x Per Day - [ ] Check project build status (CI/CD) - [ ] Review social media engagement on recent posts ## Once Daily (morning) - [ ] Weather forecast (human goes running) - [ ] Market summary (if trading cron hasn't run yet) ## Rules - Late night (11 PM - 8 AM): HEARTBEAT_OK unless truly urgent - If nothing actionable: reply HEARTBEAT_OK (saves tokens) - Batch updates into ONE message, don't spam - Track last check times in memory/heartbeat-state.json
{
"lastChecks": {
"email": "2026-02-22T14:30:00Z",
"twitter": "2026-02-22T14:30:00Z",
"calendar": "2026-02-22T13:00:00Z",
"weather": "2026-02-22T08:00:00Z",
"builds": "2026-02-22T12:00:00Z"
}
}Your First Cron Job: The Night Shift
The single most important automation is nightly memory consolidation. Every night at 2 AM, your agent reviews the day, extracts key learnings, and updates the knowledge base. This is the glue that holds the entire three-layer brain together.
openclaw cron add \
--name "Nightly Memory Consolidation" \
--cron "0 2 * * *" \
--tz "America/Chicago" \
--session isolated \
--message "Review today's daily note (memory/YYYY-MM-DD.md). \
Extract key decisions, learnings, and status changes. \
Update relevant knowledge base files. \
Update tacit.md if any new preferences were discovered. \
If a project changed status, update its file. \
Log what you consolidated in today's daily note." \
--model "sonnet"The Essential Cron Setup (4 Jobs)
Here's the minimum viable cron configuration. These four jobs cover 90% of what most people need:
Wake up to a summary of everything that matters.
openclaw cron add \
--name "Morning Brief" \
--cron "0 8 * * *" \
--tz "America/Chicago" \
--session isolated \
--message "Morning briefing: Check emails, review \
calendar for next 24h, check project statuses, \
overnight social mentions, weather. Read yesterday's \
daily note for context. Compile into a concise \
brief with action items. Keep under 20 bullets." \
--model "sonnet" --announce \
--channel discord --to "channel:YOUR_ID"Watches your mentions, logs engagement data.
openclaw cron add \
--name "Social Monitor" \
--cron "0 */4 * * *" \
--tz "America/Chicago" \
--session isolated \
--message "Check social mentions and replies since \
last check. Log engagement metrics. Handle simple \
interactions (likes, thank-yous). Flag anything \
needing human response. If nothing actionable, \
say HEARTBEAT_OK." \
--model "sonnet" --delivery noneBig-picture review of the past week.
openclaw cron add \
--name "Weekly Review" \
--cron "0 9 * * 1" \
--tz "America/Chicago" \
--session isolated \
--message "Weekly review: Read daily notes from the \
past 7 days. Summarize what was accomplished, \
what's still pending, any recurring blockers. \
Suggest priorities for this week. Check revenue \
metrics if available." \
--model "sonnet" --announce \
--channel discord --to "channel:YOUR_ID"The night shift that keeps your memory system healthy.
(Config shown above — this is the most important one)
After one week: 7 days of consolidated learnings and 7 morning briefings.
After one month: a rich, searchable history of everything that happened.
After three months: a genuine second brain that actually works.
Common Mistakes
Start with 4. Add more only when you feel a specific gap. 15 cron jobs running on expensive models will cost you $50+/month and flood your channels. Less is more.
Your nightly consolidation doesn't need GPT-4/Opus. Use Sonnet, Haiku, or GPT-4o-mini for maintenance tasks. Save the big models for analysis and decision-making.
Always include "if nothing actionable, say HEARTBEAT_OK" in your cron messages. Otherwise your agent will manufacture something to report, wasting tokens and your attention.
Unless the cron is silent (delivery: none), don't schedule announcements between 11 PM and 7 AM. Your agent's 3 AM social media report can wait until your morning briefing.
Advanced: Chaining Crons
As your system matures, you can create cron chains — where one job's output feeds another:
Each cron reads from shared files (the knowledge base and daily notes), so they naturally coordinate without needing to "talk" to each other. It's like a relay race where each runner picks up where the last one left off.
Your agent now works while you sleep. But before we give it real tools and real access, we need to talk about the thing that keeps you safe: security.
Share this chapter
Chapter navigation
6 of 36