Cron vazifalari (Gateway rejalashtirgichi)
Cron vs Heartbeat? Qaysi birini qachon ishlatish bo‘yicha ko‘rsatmalar uchun Cron vs Heartbeat ga qarang.Cron — Gateway’ning ichki rejalashtirgichi. U vazifalarni saqlab qoladi, agentni kerakli vaqtda uyg‘otadi va ixtiyoriy ravishda natijani chatga yetkazishi mumkin. Agar “buni har tongda ishga tushir” yoki “20 daqiqadan keyin agentni turt” desangiz, mexanizm — cron. Nosozliklarni bartaraf etish: /automation/troubleshooting
Qisqacha
- Cron Gateway ichida ishlaydi (model ichida emas).
- Vazifalar
~/.openclaw/cron/ostida saqlanadi, shuning uchun qayta ishga tushirishlar jadvalni yo‘qotmaydi. - Ikki ijro uslubi:
- Asosiy sessiya: tizim hodisasini navbatga qo‘ying, so‘ng keyingi heartbeat’da ishga tushiring.
- Izolyatsiyalangan:
cron:<jobId>da alohida agent aylanishini ishga tushiring, yetkazib berish bilan (standart bo‘yicha e’lon qilinadi yoki yo‘q).
- Uyg‘otishlar birinchi darajali: vazifa “hozir uyg‘ot” yoki “keyingi heartbeat”ni so‘rashi mumkin.
Tezkor boshlash (amaliy)
Bir martalik eslatma yarating, mavjudligini tekshiring va darhol ishga tushiring:Tool-chaqiruv muqobillari (Gateway cron tool)
Kanonik JSON shakllari va misollar uchun JSON schema for tool calls sahifasiga qarang.Cron vazifalari qayerda saqlanadi
Cron jobs are persisted on the Gateway host at~/.openclaw/cron/jobs.json by default.
The Gateway loads the file into memory and writes it back on changes, so manual edits
are only safe when the Gateway is stopped. Prefer openclaw cron add/edit or the cron
tool call API for changes.
Boshlovchilar uchun sodda tushuntirish
Cron vazifasini shunday tasavvur qiling: qachon bajariladi + nima bajariladi.-
Jadvalni tanlang
- Bir martalik eslatma →
schedule.kind = "at"(CLI:--at) - Takrorlanuvchi vazifa →
schedule.kind = "every"yokischedule.kind = "cron" - Agar ISO vaqt belgisi timezone ko‘rsatmasa, u UTC sifatida qabul qilinadi.
- Bir martalik eslatma →
-
Qayerda bajarilishini tanlang
sessionTarget: "main"→ run during the next heartbeat with main context.sessionTarget: "isolated"→ run a dedicated agent turn incron:<jobId>.
-
Choose the payload
- Main session →
payload.kind = "systemEvent" - Isolated session →
payload.kind = "agentTurn"
- Main session →
schedule.kind = "at") delete after success by default. Set
deleteAfterRun: false to keep them (they will disable after success).
Concepts
Jobs
A cron job is a stored record with:- a schedule (when it should run),
- a payload (what it should do),
- optional delivery mode (announce or none).
- optional agent binding (
agentId): run the job under a specific agent; if missing or unknown, the gateway falls back to the default agent.
jobId (used by CLI/Gateway APIs).
In agent tool calls, jobId is canonical; legacy id is accepted for compatibility.
One-shot jobs auto-delete after success by default; set deleteAfterRun: false to keep them.
Schedules
Cron supports three schedule kinds:at: one-shot timestamp viaschedule.at(ISO 8601).every: fixed interval (ms).cron: 5-field cron expression with optional IANA timezone.
croner. If a timezone is omitted, the Gateway host’s
local timezone is used.
Main vs isolated execution
Main session jobs (system events)
Main jobs enqueue a system event and optionally wake the heartbeat runner. They must usepayload.kind = "systemEvent".
wakeMode: "now"(default): event triggers an immediate heartbeat run.wakeMode: "next-heartbeat": event waits for the next scheduled heartbeat.
Isolated jobs (dedicated cron sessions)
Isolated jobs run a dedicated agent turn in sessioncron:<jobId>.
Key behaviors:
- Prompt is prefixed with
[cron:<jobId> <job name>]for traceability. - Each run starts a fresh session id (no prior conversation carry-over).
- Default behavior: if
deliveryis omitted, isolated jobs announce a summary (delivery.mode = "announce"). delivery.mode(isolated-only) chooses what happens:announce: deliver a summary to the target channel and post a brief summary to the main session.-
none: faqat ichki (yetkazib berish yo‘q, asosiy sessiya xulosasi yo‘q).
wakeModecontrols when the main-session summary posts:- 3.
now: darhol heartbeat. next-heartbeat: waits for the next scheduled heartbeat.
- 3.
4. Yuklama shakllari (nima ishga tushadi)
Two payload kinds are supported:systemEvent: main-session only, routed through the heartbeat prompt.agentTurn: isolated-session only, runs a dedicated agent turn.
agentTurn fields:
message: required text prompt.model/thinking: optional overrides (see below).timeoutSeconds: optional timeout override.
delivery.mode:none|announce.delivery.channel:lastor a specific channel.delivery.to: channel-specific target (phone/chat/channel id).-
delivery.bestEffort: e’lonni yetkazish muvaffaqiyatsiz bo‘lsa, vazifani muvaffaqiyatsiz deb belgilamaslik.
delivery.channel/delivery.to
to target the chat instead. When delivery.mode = "none", no summary is posted to the main session.
If delivery is omitted for isolated jobs, OpenClaw defaults to announce.
Announce delivery flow
Whendelivery.mode = "announce", cron delivers directly via the outbound channel adapters.
The main agent is not spun up to craft or forward the message.
Behavior details:
- Content: delivery uses the isolated run’s outbound payloads (text/media) with normal chunking and channel formatting.
- Heartbeat-only responses (
HEARTBEAT_OKwith no real content) are not delivered. - If the isolated run already sent a message to the same target via the message tool, delivery is skipped to avoid duplicates.
- Missing or invalid delivery targets fail the job unless
delivery.bestEffort = true. - A short summary is posted to the main session only when
delivery.mode = "announce". - The main-session summary respects
wakeMode:nowtriggers an immediate heartbeat andnext-heartbeatwaits for the next scheduled heartbeat.
Model and thinking overrides
Isolated jobs (agentTurn) can override the model and thinking level:
model: Provider/model string (e.g.,anthropic/claude-sonnet-4-20250514) or alias (e.g.,opus)thinking: Thinking level (off,minimal,low,medium,high,xhigh; GPT-5.2 + Codex models only)
model on main-session jobs too, but it changes the shared main
session model. We recommend model overrides only for isolated jobs to avoid
unexpected context shifts.
Resolution priority:
- Job payload override (highest)
- Hook-specific defaults (e.g.,
hooks.gmail.model) - Agent config default
Delivery (channel + target)
Isolated jobs can deliver output to a channel via the top-leveldelivery config:
delivery.mode:announce(deliver a summary) ornone.delivery.channel:whatsapp/telegram/discord/slack/mattermost(plugin) /signal/imessage/last.delivery.to: channel-specific recipient target.
sessionTarget: "isolated").
If delivery.channel or delivery.to is omitted, cron can fall back to the main session’s
“last route” (the last place the agent replied).
Maqsad formatiga oid eslatmalar:
- Slack/Discord/Mattermost (plagin) maqsadlari noaniqlikni oldini olish uchun aniq prefikslardan foydalanishi kerak (masalan,
channel:<id>,user:<id>). - Telegram mavzulari
:topic:shaklidan foydalanishi kerak (quyida qarang).
Telegram yetkazib berish maqsadlari (mavzular / forum tarmoqlari)
Telegrammessage_thread_id orqali forum mavzularini qo‘llab-quvvatlaydi. Cron orqali yetkazib berish uchun siz mavzu/tarmoqni to maydoniga kodlashingiz mumkin:
-1001234567890(faqat chat identifikatori)-1001234567890:topic:123(afzal: aniq mavzu belgisi)-1001234567890:123(qisqa shakl: raqamli suffiks)
telegram:... / telegram:group:... kabi prefiksli maqsadlar ham qabul qilinadi:
telegram:group:-1001234567890:topic:123
6. Asbob chaqiruvlari uchun JSON sxemasi
Gatewaycron.* asboblarini bevosita chaqirishda (agent asbob chaqiruvlari yoki RPC) ushbu shakllardan foydalaning.
CLI flaglari 20m kabi insoniy davomiyliklarni qabul qiladi, ammo asbob chaqiruvlari schedule.at uchun ISO 8601 satrini va schedule.everyMs uchun millisekundlarni ishlatishi kerak.
cron.add parametrlari
- Bir martalik, asosiy sessiya vazifasi (tizim hodisasi):
schedule.kind:at(at),every(everyMs) yokicron(expr, ixtiyoriytz).schedule.atISO 8601 ni qabul qiladi (vaqt mintaqasi ixtiyoriy; ko‘rsatilmasa UTC sifatida qabul qilinadi).everyMs— millisekundlarda.sessionTarget"main"yoki"isolated"bo‘lishi vapayload.kindbilan mos kelishi kerak.- Ixtiyoriy maydonlar:
agentId,description,enabled,deleteAfterRun(atuchun sukut bo‘yicha true),delivery. wakeModeko‘rsatilmasa, sukut bo‘yicha"now"bo‘ladi.
cron.update parametrlari
jobIdkanonik; moslik uchunidham qabul qilinadi.- Agent bog‘lanishini tozalash uchun patch’da
agentId: nulldan foydalaning.
cron.run va cron.remove parametrlari
Saqlash va tarix
- Vazifalar ombori:
~/.openclaw/cron/jobs.json(Gateway tomonidan boshqariladigan JSON). - Ishga tushirish tarixi:
~/.openclaw/cron/runs/<jobId>.jsonl(JSONL, avtomatik tozalanadi). - Ombor yo‘lini almashtirish: konfiguratsiyada
cron.store.
Konfiguratsiya
cron.enabled: false(konfiguratsiya)OPENCLAW_SKIP_CRON=1(muhit)
CLI tezkor boshlash
Bir martalik eslatma (UTC ISO, muvaffaqiyatdan so‘ng avtomatik o‘chiriladi):--due to only run when due):
Gateway API surface
cron.list,cron.status,cron.add,cron.update,cron.removecron.run(force or due),cron.runsFor immediate system events without a job, useopenclaw system event.
Troubleshooting
“Nothing runs”
-
- Cron yoqilganini tekshiring:
cron.enabledvaOPENCLAW_SKIP_CRON.
- Cron yoqilganini tekshiring:
- Check the Gateway is running continuously (cron runs inside the Gateway process).
- For
cronschedules: confirm timezone (--tz) vs the host timezone.
A recurring job keeps delaying after failures
- OpenClaw applies exponential retry backoff for recurring jobs after consecutive errors: 30s, 1m, 5m, 15m, then 60m between retries.
- Backoff resets automatically after the next successful run.
- One-shot (
at) jobs disable after a terminal run (ok,error, orskipped) and do not retry.
Telegram delivers to the wrong place
- For forum topics, use
-100…:topic:<id>so it’s explicit and unambiguous. - If you see
telegram:...prefixes in logs or stored “last route” targets, that’s normal; cron delivery accepts them and still parses topic IDs correctly.