Skip to content

Native Scheduler

OS-level scheduled jobs that run scripts directly — no gateway, no LLM, no agent session. Zero token cost.

Use the native scheduler for anything that can be expressed as a shell command without needing an LLM to interpret the results.

When to Use

  • Git sync / workspace backupgit add -A && git commit && git push on a timer
  • Data collectioncurl an API, write to a file, let an agent cron analyze it later
  • Log rotation / cleanup — Move, compress, or delete old files
  • Health checks — Ping a service, write status to a file
  • File synchronization — Rsync, rclone, or custom sync scripts

Key principle: If the task is "run this command," use native scheduler. If the task is "figure out what to do," use a gateway cron.

OpenClaw's Native Scheduler Plugin

OpenClaw includes a native_scheduler tool that manages launchd (macOS) and systemd (Linux) jobs with agent-aware features:

  • Wrapper metadata — Each job gets execution tracking (start time, duration, exit code)
  • Failure callbacks — Notify the agent when a job fails (can trigger an agent session to investigate)
  • Result delivery — Route job output back to agent sessions (prompt, message, or noop)
jsonc
// Example: hourly git sync via native_scheduler tool
{
  "id": "workspace-backup",
  "command": ["/bin/bash", "-c", "cd ~/.openclaw/workspace && git add -A && git diff --cached --quiet || git commit -m 'auto-backup' && git push"],
  "calendar": [{ "minute": 45 }],
  "description": "Hourly workspace backup to git",
  "defaultFailureResult": { "result": "prompt" }
}

Failure Callbacks

When a native job fails, you can route the failure to an agent:

jsonc
{
  "failureCallback": {
    "type": "openclaw-event",
    "text": "workspace-backup job failed — investigate",
    "mode": "queue"
  }
}

This bridges the gap: the job itself runs without AI, but failures get AI-assisted diagnosis.

Direct launchd / systemd

You can also manage OS schedulers directly if you prefer:

macOS (launchd)

xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.agent.git-sync</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/bash</string>
    <string>/path/to/sync.sh</string>
  </array>
  <key>StartInterval</key>
  <integer>3600</integer>
  <key>StandardOutPath</key>
  <string>/tmp/git-sync.log</string>
  <key>StandardErrorPath</key>
  <string>/tmp/git-sync.err</string>
</dict>
</plist>

Linux (systemd timer)

ini
# /etc/systemd/system/git-sync.timer
[Unit]
Description=Hourly git sync

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target

Cost Comparison

SystemPer-run costMonthly cost (hourly job)
Gateway cron (Opus)~$0.03~$21.60
Gateway cron (Haiku)~$0.002~$1.44
Sentinel (polling only)$0$0
Native scheduler$0$0

For a workspace backup that runs every hour, using a gateway cron instead of native scheduler wastes $1.44–$21.60/month on LLM calls for a task that's just git commit && git push.

Combining Systems

The most effective setups combine all three:

Native Scheduler (zero cost)
  └─ Hourly git sync, data collection, file cleanup

Sentinel Watchers (cost on trigger only)
  └─ Price alerts, API health monitoring, on-chain events

Gateway Crons (full LLM cost)
  └─ Morning briefing, governance analysis, email triage

Native scheduler collects data → Sentinel watches for interesting conditions → Gateway cron provides AI analysis when needed. Each layer uses the cheapest tool that can handle the job.

Built with OpenClaw 🤖