Skip to content

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 schedule in 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_job executes a command in the image of an already deployed service, e.g. database migrations after a deploy.

Short version for the agent ​

  1. Recurring task: add a separate service with schedule: { cron, command } to the contract, plan_deployment, apply_deployment. The deployment is healthy at once; the next run is in get_deployment under job.next_run_at.
  2. One-off task: run_job with project, service and command. The call waits up to 25 seconds and returns status, exit code and output; if the command runs longer, repeat get_job_run with wait_s: 25.
  3. A run succeeds when the command ends with exit code 0. Failed runs give reason and docs_ref.

Job with a schedule ​

json
{
  "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"
      }
    }
  ]
}
FieldValuesDefault
schedule.cronFive 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.commandProgram and arguments as a liststart_command, otherwise the image's entrypoint and command
schedule.timeout_s1–3600600
schedule.timezoneIANA name, e.g. Europe/Berlin, UTCEurope/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 skipped with JOB_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_service does not run and cancels open runs; start schedules 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 ​

json
{ "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: 0 answers at once with the run in queued.
  • At most one run_job run 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:

json
{
  "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.

ReasonMeaning
JOB_EXIT_NONZEROThe 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_TIMEOUTtimeout_s exceeded, the run was ended
OOM_KILLEDMemory limit exceeded; raise resources.memory_mb
IMAGE_PULL_FAILED, START_FAILEDImage could not be loaded or command could not be started (e.g. program missing in the image)
JOB_OVERLAPSkipped because the previous run was still running
PROJECT_STOPPEDSkipped because the project is stopped
WAITING_FOR_CAPACITYNo runner had enough free memory for 15 minutes
NODE_LOST, NODE_RESTARTEDThe 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.