📚Academy
likeone
online

Cron & Scheduling

Autonomous agents need to know when to wake up. Cron is the universal scheduling language — created in the 1970s, still running on virtually every server in the world. This lesson teaches you to read, write, and debug cron expressions, schedule agent fleets without conflicts, and choose between cron, event-driven, and always-on scheduling.

Three Scheduling Modes

Every agent runs in one of three modes. Choosing the wrong mode is a common architectural mistake:

Cron-based (time-triggered)

Agent wakes on a fixed schedule — every 5 minutes, daily at 9 AM, weekly on Mondays. Predictable, efficient, but has latency (up to one full interval). Best for: reports, backups, periodic health checks, batch processing.

Event-driven (trigger-based)

Agent sleeps until something happens — a webhook fires, a database row is inserted, a file is uploaded. Zero latency for the triggering event. Efficient because the agent uses zero resources while sleeping. Best for: incoming requests, real-time processing, notifications.

Always-on (continuous)

Agent runs in a permanent loop, continuously monitoring and acting. Instant response time but highest resource cost. Best for: chat agents, real-time dashboards, security monitoring, anything that must respond in under a second.

The Cron Expression Format

A cron expression is five fields separated by spaces. Each field controls one dimension of timing:

*  *  *  *  *
        
        └─ Day of week (0-6, Sun=0)
      └──── Month (1-12)
    └─────── Day of month (1-31)
  └────────── Hour (0-23)
└─────────────── Minute (0-59)
* = every value (wildcard)
*/N = every N units (*/5 in minute = every 5 minutes)
1-5 = range (in weekday field: Monday through Friday)
1,15 = specific values (1st and 15th of the month)
Common examples:
*/5 * * * * — every 5 minutes (health checks)
0 9 * * 1-5 — 9:00 AM weekdays (daily standup report)
0 0 * * * — midnight every day (nightly backup)
30 17 * * 5 — 5:30 PM every Friday (weekly summary)
0 */6 * * * — every 6 hours (periodic sync)

⏰ Cron Expression Builder

Build Your Schedule
* * * * *
Every minute, every hour, every day

Real-World: How Like One Uses Cron

Like One's fleet uses all three scheduling modes in production right now:

# GCP Watcher — systemd timers (upgraded from crontab)
brain-heartbeat.timer  → every 5 min  → updates machine_heartbeats table
brain-health.timer     → every 15 min → checks site, brain, edge functions, academy

# Event-driven edge functions
subscribe              → fires on POST → adds subscriber to database
stripe-webhook         → fires on Stripe event → processes payment

# Always-on
faye-chat              → always listening → responds to user messages

Scheduling Conflicts

When multiple resource-heavy agents fire at the same time, they compete for CPU, memory, and API rate limits. This is called a scheduling conflict. The fix is simple: stagger start times.

Bad: 5 agents all scheduled at 0 9 * * * (9:00 AM) — they all wake up and hit the API simultaneously.
Good: Stagger them: 0 9, 2 9, 4 9, 6 9, 8 9 — two minutes apart, no contention.
🔒

This lesson is for Pro members

Unlock all 520+ lessons across 52 courses with Academy Pro.

Already a member? Sign in to access your lessons.

Academy
Built with soul — likeone.ai