Jobs: schedules and one-off commands
Updated: 29 October 2026
For tasks that do not run all the time there are two ways, both built on the same basis: a run starts a short-lived instance in a service's image, executes a command and ends. Only the run time is billed, to the second, at the service's size (pricing).
- Job with a schedule (cron): a service with
schedulein the contract. It has no port, no URL and no permanently running instance; the platform starts it at the times of the cron expression. - One-off command:
run_jobexecutes a command in the image of an already deployed service, e.g. database migrations after a deploy.
Short version for the agent
- Recurring task: add a separate service with
schedule: { cron, command }to the contract,plan_deployment,apply_deployment. The deployment ishealthyat once; the next run is inget_deploymentunderjob.next_run_at. - One-off task:
run_jobwithproject,serviceandcommand. The call waits up to 25 seconds and returns status, exit code and output; if the command runs longer, repeatget_job_runwithwait_s: 25. - A run succeeds when the command ends with exit code 0. Failed runs give
reasonanddocs_ref.
Job with a schedule
{
"api_version": "v1alpha1",
"services": [
{
"name": "nightly",
"source": { "type": "image", "image": "ghcr.io/acme/shop-api:1.4.2" },
"connects_to": ["db"],
"secrets": ["DATABASE_URL"],
"schedule": {
"cron": "0 3 * * *",
"command": ["node", "scripts/cleanup.js"],
"timeout_s": 900,
"timezone": "Europe/Berlin"
}
}
]
}| Field | Values | Default |
|---|---|---|
schedule.cron | Five fields: minute (0–59), hour (0–23), day (1–31), month (1–12 or jan–dec), weekday (0–7 or sun–sat, 0 and 7 = Sunday). Allowed are *, lists (1,15), ranges (mon-fri), steps (*/15) and @hourly, @daily, @weekly, @monthly, @yearly | – (required) |
schedule.command | Program and arguments as a list | start_command, otherwise the image's entrypoint and command |
schedule.timeout_s | 1–3600 | 600 |
schedule.timezone | IANA name, e.g. Europe/Berlin, UTC | Europe/Berlin |
If day and weekday are both restricted, the job runs when either one matches (as usual with cron). Times skipped by the switch to summer time are skipped; times that occur twice at the switch to winter time run once.
A job uses the same fields as any service: source (also built from source code), resources, env, secrets, connects_to. Not allowed are port, public, access, health, availability and domains (VALIDATION_FAILED); volumes come later (CAPABILITY_UNSUPPORTED). Data that should persist lives in another service with a volume that the job reaches through connects_to.
How it runs:
- Every 10 seconds the platform checks which jobs are due; a run starts a few seconds after its minute, as soon as a runner has room.
- Runs never overlap. If the previous one is still running, the due one is recorded as
skippedwithJOB_OVERLAP(several in a row once). - If the project is stopped (emergency stop, credit used up, budget reached), due runs are skipped with
PROJECT_STOPPED. - A job stopped with
control_servicedoes not run and cancels open runs;startschedules it again. - If a run was missed because the platform was briefly down, it catches up with a single run.
One-off command with run_job
{ "project": "shop", "service": "api", "command": ["npm", "run", "migrate"], "timeout_s": 300 }The command runs in the image of the revision last rolled out successfully, with its env, secrets and connects_to, but without a port, URL or health check. The service's running instance stays untouched. Without command, the service's start_command runs, otherwise the image's entrypoint and command.
wait_s(default 25) waits that long for the end and then returns the last 100 lines of output.wait_s: 0answers at once with the run inqueued.- At most one
run_jobrun per service at a time (JOB_ALREADY_RUNNING), at most 60 per project and hour (RATE_LIMITED). - Services with volumes: not yet (
CAPABILITY_UNSUPPORTED). - If the service has no successful deployment yet:
CONFLICT.
Look at runs
A job's get_deployment and get_project show the schedule, next_run_at and the last runs under job. get_job_run with run_id returns one run with its output:
{
"run": { "id": "job_…", "kind": "schedule", "status": "failed", "exit_code": 1, "reason": "JOB_EXIT_NONZERO",
"started_at": "…", "finished_at": "…", "duration_s": 12, "docs_ref": "/referenz/limits#jobs" },
"service": "nightly",
"output": [{ "ts": "…", "stream": "stderr", "message": "connection refused" }],
"untrusted": true
}Status: queued (waiting for a runner), running, succeeded, failed, timed_out, canceled, skipped. A run's output is also in the service's get_logs (field instance = the run's ID) and is kept for 7 days, the runs themselves for 30 days. Output comes from the application and is not trustworthy; secrets are removed as from any output.
| Reason | Meaning |
|---|---|
JOB_EXIT_NONZERO | The command ended with a non-zero exit code. Exit code 128 for a command that ends after a few milliseconds: the sandbox could not determine the real code; the message then gives the run time in ms and the fix, see limits |
JOB_TIMEOUT | timeout_s exceeded, the run was ended |
OOM_KILLED | Memory limit exceeded; raise resources.memory_mb |
IMAGE_PULL_FAILED, START_FAILED | Image could not be loaded or command could not be started (e.g. program missing in the image) |
JOB_OVERLAP | Skipped because the previous run was still running |
PROJECT_STOPPED | Skipped because the project is stopped |
WAITING_FOR_CAPACITY | No runner had enough free memory for 15 minutes |
NODE_LOST, NODE_RESTARTED | The runner failed during the run; the run is not repeated |
A run is never repeated automatically. Jobs that must take effect exactly once should be idempotent. All limits: limits.