Skip to main content
By default, a job runs once and isn’t restarted. You can set up a job to be automatically restarted when its container exits with an error.
Automatic restarts aren’t available for Serverless AI endpoints.

Prerequisites

  • Install and configure the Nebius AI Cloud CLI. Check that your project ID is saved in the Nebius AI Cloud CLI profile configuration:
  • Make sure you are in a group that has at least the editor role within your tenant or project; for example, the default editors group. You can check this in the Administration → IAM section of the web console.

Configuring automatic restarts

To turn automatic restarts on or off, set the restart policy when you create the job. In the CLI, use the --restart-policy parameter. In the SDKs and the REST API, use the restart attempts parameter: Spec.RestartAttempts in Go, spec.restart_attempts in Python and spec.restartAttempts in JavaScript and the REST API. The values correspond as follows: Automatic restarts occur when your container exits with an error while the job is running. They are useful for workloads that can fail transiently and succeed on a retry, for example, a training workload that can resume from a checkpoint after a crash. For example, to create a job whose container restarts on failure:
Instead of ..., specify the other job parameters, as described in How to create a job.

When jobs aren’t restarted

The restart policy responds only to the container’s own exit code. It doesn’t recover from:
  • No available capacity at start: if the requested compute can’t be allocated when the job starts.
  • Preemption: if you run on preemptible compute and Nebius AI Cloud reclaims (preempts) the underlying virtual machine (VM).
  • The underlying VM stopping unexpectedly.
  • Startup failures and timeouts.
In these cases, the job moves to the ERROR status and isn’t restarted automatically. To run it again, create a new job or restart it, for example with nebius ai job restart in the CLI.
For resilience against preemption or lost capacity, design your workload to be resumable, for example, write and resume from checkpoints, and resubmit the job rather than relying on automatic restarts.