Skip to main content
Operating System

Cron Jobs

Schedule recurring commands and agent sessions in agentOS VMs.

  • Cron expressions for flexible scheduling (e.g. "0 9 * * *" for 9 AM daily)
  • Two action types: exec for commands, session for agent sessions
  • Overlap modes: allow, skip, or queue concurrent executions
  • Event streaming via cronEvent for monitoring job execution

Schedule a command

Run a shell command on a recurring schedule.

Schedule an agent session

Create a recurring agent session that runs a prompt on a schedule.

Overlap modes

Control what happens when a cron job triggers while a previous execution is still running.

ModeBehavior
"skip"Skip this trigger if the previous run is still active
"allow"Allow concurrent executions (default)
"queue"Queue this trigger and run it after the previous one finishes

Monitor cron events

Subscribe to cronEvent to track job execution.

List and cancel cron jobs

Example: Heartbeat pattern

Schedule a recurring agent session to periodically check on a task. This is the core pattern behind OpenClaw, where an agent wakes up on a schedule to review progress, take action, and go back to sleep.

await agent.scheduleCron({
  schedule: "*/30 * * * *",
  overlap: "skip",
  action: {
    type: "session",
    agentType: "pi",
    prompt: "Check the status of open issues and take any necessary action",
  },
});

The agent sleeps between executions and only consumes resources when the cron job fires.

Recommendations

  • Use "skip" overlap mode for most jobs. This prevents unbounded concurrency if a job takes longer than the interval. The default is "allow".
  • Use "queue" when every trigger must execute, even if they back up.
  • Cron jobs keep the actor alive while executing. The actor can sleep between executions.
  • Provide a custom id when scheduling to make it easier to manage and cancel jobs later.