Module 12 • Advanced

Simple Automation

Master simple automation with cron jobs: learn scheduling, expressions, and best practices for reliable task automation in OpenClaw.

📊 Module Progress

Complete objectives and quizzes to unlock your badge!
0/9 Tasks Completed

🎯 Learning Objectives

Understand Cron Scheduling — Learn how to schedule tasks automatically.
Design Basic Cron Jobs — Create simple cron expressions for daily/weekly tasks.
Use Different Schedule Types — Apply at, every, and cron schedule types.
Create Real Automation Scripts — Build actual cron jobs for notifications and backups.

📚 Theory

What is Automation?

Automation = Tasks that run automatically at specific times or intervals.

OpenClaw can do things on a schedule — like a personal assistant who works while you sleep.

Examples

How OpenClaw Handles Automation: Cron Jobs

Cron is a time-based job scheduler. OpenClaw uses it to schedule tasks.

Cron Job Structure:

{
  "name": "Morning Weather",
  "schedule": {
    "kind": "cron",
    "expr": "0 8 * * *",
    "tz": "Asia/Kuala_Lumpur"
  },
  "payload": {
    "kind": "systemEvent",
    "text": "Check weather in Ipoh and send to Telegram"
  },
  "sessionTarget": "main"
}

- name: Identifies the job.
- schedule: When to run (8AM daily, MYT timezone).
- payload: What to do.
- sessionTarget: Where to run it (main session = your chat).

Schedule Types

1. at — One-Time

Run once at a specific date/time.

"schedule": { "kind": "at", "at": "2026-12-25T08:00:00+08:00" }

2. every — Recurring Interval

Run every X minutes/hours/days.

"schedule": { "kind": "every", "everyMs": 3600000 }  // Every hour

3. cron — Cron Expression

Run on a schedule (like "every Monday at 9AM").

"schedule": { "kind": "cron", "expr": "0 9 * * 1", "tz": "Asia/Kuala_Lumpur" }

Cron expression breakdown:
0 9 * * 1
│ │ │ │ └─ Day of week (0-6, 0=Sunday)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)

Setting Up Your First Cron Job

Method 1: Via Chat (Easiest)

You: "Remind me in 20 minutes to check the oven."
JiXe: "Got it! I'll remind you at [time]." creates cron job

Method 2: Via Config (Advanced)

Edit openclaw.json → add to cron.jobs array → restart gateway.

Best Practices

  1. Don't Overload — Too many cron jobs = OpenClaw busy all the time. Keep it reasonable (5-10 jobs max).
  2. Batch Similar Checks — Instead of 3 separate jobs (email, calendar, weather), make 1 job that does all 3.
  3. Use Heartbeat for Frequent Checks — If you need something checked every 30 minutes, use HEARTBEAT.md instead of cron.

Key Takeaway

Automation makes OpenClaw work for you even when you're not actively chatting. Start simple, then expand!

🧪 Hands-On Exercise

Design a cron job for a real use case.

Step 1: Choose Your Use Case

Pick one: Daily weather report at 8AM • Reminder to drink water every 2 hours • Weekly summary every Sunday at 6PM • Custom: ________

Step 2: Determine Schedule Type

One-time? → kind: "at" | Regular interval? → kind: "every" | Complex schedule? → kind: "cron"

Step 3: Write the Cron Expression (if using cron)

Example: Every day at 8AM
"expr": "0 8 * * *"

Your turn:
Use case: ________
Cron expression: ________

Step 4: Write the Payload (What to do)

Example:

{
  "payload": {
    "kind": "systemEvent",
    "text": "Check weather in Ipoh and send to Telegram"
  }
}

Your turn: Action: ________

Step 5: Assemble Full Cron Job

{
  "name": "YOUR JOB NAME",
  "schedule": {
    "kind": "YOUR KIND",
    "expr": "YOUR EXPRESSION"
  },
  "payload": {
    "kind": "systemEvent",
    "text": "YOUR ACTION"
  },
  "sessionTarget": "main"
}

Example Completed Job (Daily Backup)

{
  "name": "Daily Backup",
  "schedule": {
    "kind": "cron",
    "expr": "0 2 * * *",
    "tz": "Asia/Kuala_Lumpur"
  },
  "payload": {
    "kind": "systemEvent",
    "text": "Backup C:\\Important\\ to cloud storage"
  },
  "sessionTarget": "isolated",
  "failureAlert": {
    "channel": "telegram",
    "to": "YOUR-CHAT-ID",
    "after": 1
  }
}

Bonus: Uses isolated session and failure alert to Telegram.

📝 Quiz: Automation Basics

Q1: Cron is used for:

A
Playing music
B
Scheduling automated tasks
C
Editing videos
D
Deleting files

Q2: Which schedule type runs "every 2 hours"?

A
kind: "at"
B
kind: "every" with everyMs: 7200000
C
kind: "cron" with expr "*/2 * * * *"
D
kind: "magic"

Q3: What does sessionTarget: "main" mean?

A
Run in isolated session
B
Run in the main chat session
C
Run on another planet
D
Run in a cave

Q4: Cron expression "0 8 * * *" means:

A
Every 8 minutes
B
Every day at 8AM
C
Every 8th day of month
D
At 8PM only on weekdays

Q5: Best practice for cron jobs:

A
Create 100 jobs
B
Keep it reasonable (5-10 max)
C
Never use them
D
Delete them immediately
Badge Earned!
Automator ⚡

You've completed all objectives and quizzes!