DEV Community

Hex
Hex

Posted on • Originally published at openclawplaybook.ai

OpenClaw Cron Jobs: Automate Your AI Agent's Daily Tasks

An AI agent that only responds when you talk to it is a chatbot. An agent that does things on its own schedule — sends morning briefings, monitors infrastructure, publishes content, runs weekly reviews — that's an employee.

OpenClaw's cron system is what makes that possible. It's a built-in scheduler that persists jobs, wakes the agent at precise times, and optionally delivers output to any messaging channel. No external services. No fragile bash crontabs. It lives inside the Gateway and survives restarts.

Why Not Just Use Regular Cron?

You could schedule a shell command that pokes your AI. But you'd lose:

  • Session isolation — each run gets a clean session, so noisy tasks don't pollute your main chat
  • Delivery routing — output automatically goes to Slack, Telegram, WhatsApp, Discord, or wherever you need it
  • Model overrides — use a cheaper model for routine checks, a powerful one for weekly deep dives
  • Retry and backoff — transient failures (rate limits, network blips) are retried automatically with exponential backoff
  • Persistence — jobs are stored in ~/.openclaw/cron/jobs.json and survive Gateway restarts
  • Run history — every execution is logged to ~/.openclaw/cron/runs/<jobId>.jsonl for debugging

OpenClaw cron is purpose-built for AI agent scheduling. It understands sessions, models, delivery channels, and agent context in a way that system cron never will.

Two Execution Modes

Every cron job runs in one of two modes, and picking the right one matters:

Main Session Jobs

These inject a system event into your agent's main session and optionally wake the heartbeat. The agent processes the event with full conversational context — it knows what you've been working on, what happened earlier today, everything.

Use main session jobs when context matters — reminders, follow-ups, anything where the agent needs to know what's going on in your day.

Isolated Jobs

These run in a dedicated session with a clean slate. No prior conversation, no accumulated context. The agent gets just the prompt and does its work.

Isolated jobs are the workhorse. They don't clutter your main session history, they can use different models, and they deliver results directly to wherever you need them. Use these for reports, monitoring, content generation, and anything that runs independently.

Schedules: When Things Run

OpenClaw cron supports three schedule types:

One-Shot (--at)

Runs once at a specific time. Perfect for reminders. Auto-deletes after success by default.

Fixed Interval (--every)

Runs at a fixed interval. Use human-friendly duration format like 30m, 4h, 1d.

Cron Expression (--cron)

Standard 5-field cron expressions, with optional timezone. One smart detail: recurring top-of-hour schedules get a deterministic per-job stagger of up to 5 minutes to prevent all your jobs from firing simultaneously.

Delivery: Getting Results Where You Need Them

The real power of OpenClaw cron is delivery routing. Three delivery modes exist:

  • Announce (default for isolated jobs) — delivers the agent's response to the specified channel
  • Webhook — POSTs the finished event payload to a URL. Great for integrations
  • None — runs silently. The agent does its work but nothing gets delivered

A nice guardrail: if the agent's response is just HEARTBEAT_OK (nothing to report), delivery is skipped. No empty notifications cluttering your channels.

Model and Thinking Overrides

Different tasks need different models. A quick status check doesn't need the same horsepower as a weekly strategic review. Isolated cron jobs let you set model and thinking level per job — a significant cost optimization if you're running many jobs daily.

Retry and Error Handling

Things fail. APIs rate-limit. Networks drop. OpenClaw cron handles this automatically with exponential backoff. Recurring jobs stay enabled and recover on their own once the underlying issue resolves.

Cron vs Heartbeat: When to Use Which

Use heartbeat when: You want the agent to periodically check on things with full conversational context, and approximate timing is fine.

Use cron when: You need exact timing, the task is standalone, you want a different model or thinking level, or you need results delivered to a specific channel.

The most effective setup uses both. Heartbeat handles routine awareness. Cron handles precise scheduled tasks.

Real-World Examples

  • Nightly blog post — isolated job, 10 PM IST, announces to Slack
  • Morning team brief — isolated job, 9 AM weekdays, announces to team channel
  • Quick reminder — one-shot main session job, wakes heartbeat, deletes after run
  • Weekly cost review — isolated job, Fridays 10 AM, uses Opus with high thinking

Getting Started

If you haven't set up OpenClaw yet, start with the complete guide to OpenClaw. Once your agent is running, pick one recurring task you do manually today and automate it.

The goal is to wake up to work already done. Your agent should be operating like a real employee — not waiting for you to start talking to it.


Originally published at openclawplaybook.ai. Get The OpenClaw Playbook — $9.99

Top comments (0)