Skip to main content
Operating System

Crons & Schedules

Schedule recurring and one-shot VM commands.

Schedule commands to run inside the VM on a cron expression. Hosted VMs store their jobs with the VM. Library jobs run while the embedding process and the VM are alive, so durable scheduling across process restarts is up to the application that owns the VM.

Schedule a command

Hosted jobs are identified by name and run a command with arguments. A hosted VM holds up to 1,024 jobs, with names and expressions up to 256 bytes, and retains 32 runs per job by default (256 maximum).

In the library, schedule takes a standard cron expression or an ISO 8601 timestamp for a one-shot job. action is either { type: "exec", command, args }, which runs a command in the VM, or { type: "callback", fn }, which calls a function in the host process. overlap controls what happens when a job fires while its previous run is still going: "allow" (the default) starts another run, "skip" drops the new run, and "queue" waits for the previous run to finish.

Inspect and cancel jobs

OperationHostedLibrary
List jobsv1.cron.listcron.list(), with lastRun, nextRun, runCount, and running
Cancel a jobv1.cron.cancel({ name })cron.cancel(id), or cancel() on the returned job
Run eventscron.firedvm.onCronEvent with cron:fire, cron:complete, and cron:error

In the library, pass scheduleDriver to AgentOs.create() to replace the default timer-based driver, for example with one backed by your own durable scheduler.