← Back to BlogTutorial

How to Schedule Your AI Agent: Cron Jobs, Heartbeats, and Automation

H.··6 min read

I wake up to a Slack message from my AI agent. It checked my email at 6 AM, flagged two urgent invoices, summarized the rest, and put a weather report in the thread because it noticed I have an outdoor meeting later. I didn't ask it to do any of this. I scheduled it once, three months ago.

This is what an AI agent looks like when you actually use the scheduling features.

Most people set up their agent, use it as a chatbot for a week, then forget about it. The real power isn't in what you ask it to do. It's in what it does while you sleep.

Two scheduling systems, two use cases

OpenClaw gives you two ways to run tasks on autopilot: cron jobs and heartbeats. They solve different problems.

Cron jobs fire at exact times. Monday at 9 AM. Every four hours. Once a day at midnight. Each cron job runs in its own isolated session with its own context. Think of them as standalone tasks.

Heartbeats run in your main session at a configurable interval — say, every 30 minutes. The agent wakes up, checks if anything needs attention, and either acts on it or goes back to sleep. Think of them as periodic check-ins.

The rule of thumb: use cron when timing matters, use heartbeats when you want to batch checks together.

Setting up your first cron job

Let's say you want your agent to check your email every morning at 7 AM and post a summary to Slack. In your OpenClaw config:

cron:
  - schedule: "0 7 * * *"
    task: >
      Check my Gmail inbox for unread messages from the last 12 hours.
      Summarize anything important. Post the summary to #daily-digest.
      If anything is urgent, also send me a direct message.
    timezone: America/New_York

That's it. Every morning at 7 AM Eastern, your agent spins up a fresh session, checks your email, and posts the summary. You don't touch anything.

The cron syntax is standard — minute, hour, day of month, month, day of week. If you've ever written a crontab on Linux, you already know how this works.

Some schedules that work well:

# Email check - morning and afternoon
- schedule: "0 7,14 * * *"
  task: "Check email, summarize, flag urgent"

# Weekly report - Monday morning
- schedule: "0 9 * * 1"
  task: "Generate a report of everything from last week"

# Daily standup prep - 15 min before standup
- schedule: "45 8 * * 1-5"
  task: "Check my calendar, pull relevant Jira tickets, draft standup notes"

Heartbeats for the multitasker

Cron jobs are great for specific tasks at specific times. But what if you want your agent to just... keep an eye on things?

That's what heartbeats do. Configure a heartbeat interval — say, every 30 minutes — and your agent periodically checks a list of things you care about.

The beauty of heartbeats is that they run in your main session. The agent has all your conversation context, your recent requests, and your preferences. It's not starting from scratch each time.

A practical heartbeat setup:

# HEARTBEAT.md - Check these things periodically

## Every check
- Any unread Slack DMs? If urgent, alert me.

## Rotate through (2-4x per day)
- Unread emails in the last 2 hours
- Calendar events in the next 4 hours
- GitHub notifications or PR reviews needed
- Weather if I have outdoor plans today

The agent reads this file each heartbeat, picks what to check based on what it checked last time, and acts accordingly. If nothing needs attention, it goes back to sleep with a simple acknowledgment. Zero noise.

Real scheduling patterns that work

After helping dozens of people set up self-hosted AI agents, I've seen which scheduling patterns actually stick:

The morning briefing. A 7 AM cron job that pulls your email, calendar, weather, and news, then posts a single digest. This is the most popular one. People who set this up almost never disable it.

The invoice watcher. Check email every few hours for anything that looks like a bill or invoice. Extract the amount and due date. Add it to a tracking spreadsheet. One small business owner told me this saved his accountant five hours a week.

The PR reviewer. Every two hours during work days, check GitHub for PRs that need review. Pull the diff, generate a summary, and post it to the team channel. Code reviews happen faster when people actually know there's something to review.

The meeting prepper. Fifteen minutes before each calendar event, the agent pulls context — previous meeting notes, relevant documents, the attendee list — and sends you a brief. You walk into every meeting prepared without doing any prep work.

Why scheduled agents beat scheduled scripts

You could do most of this with cron + bash scripts. People have been automating email checks with scripts since the 90s. So why use an AI agent?

Because scripts are brittle and dumb.

A script checks your email and forwards anything with "invoice" in the subject line. An agent checks your email, reads the actual content, understands that the message from your lawyer about "final payment terms" is actually more urgent than the automated invoice from your hosting provider, and prioritizes accordingly.

A script breaks when Gmail changes their API response format. An agent adapts because it's working with the meaning, not the structure.

A script sends you the same formatted output every time. An agent says "nothing interesting today, skip the morning digest" when there's genuinely nothing worth reading. It respects your attention.

The compound effect

The first week of scheduled automation feels like a novelty. "Cool, my agent checks my email."

The third week, you stop checking email manually.

The third month, you realize your agent has been quietly handling things you forgot you even needed to think about. Renewals. Follow-ups. Meeting prep. The small administrative work that eats two hours of every day.

That's the compound effect of a well-scheduled agent. Each individual task is trivial. Together, they give you back a significant chunk of your day.

I helped someone through OpenClaw Setup who initially just wanted email summaries. Two weeks later, he had seven cron jobs running — email, calendar, GitHub, his accounting software, Slack monitoring, a daily journal prompt, and a weekly reflection. He spends about ten fewer hours per week on administrative tasks.

The agent doesn't make you faster at busywork. It makes the busywork disappear.

Getting started

If you're already running OpenClaw, add a cron job to your config and restart the gateway. Start with the morning email check — it's the gateway drug of agent scheduling.

If you haven't set up OpenClaw yet and want this running on your machine by tonight, book a free 15-minute call. We'll get your agent deployed with a scheduling setup tailored to your workflow. Most setups take about two hours from zero to "my agent just sent me my first morning briefing."

Related Reading

Get Your AI Agent Running

We handle the entire setup — deploy, configure, and secure OpenClaw so you don't have to.

  • Fully deployed in 48 hours
  • All channels — Slack, Telegram, WhatsApp
  • Security hardened from day one
  • 14-day hypercare included

One-time setup

$999

Complete setup, no recurring fees