Skip to main content
The sandbox exec command runs a single command inside an already-running sandbox and streams its output back to your terminal. Use it for one-off commands, scripts, and automation; for an interactive shell session, use the remote shell (connect) command instead.

Prerequisites

Set the NOVITA_API_KEY environment variable before running the command. You also need the ID of a running sandbox.

Usage

CLI
The command has the alias ex. Everything after the sandbox ID is treated as the command to execute.
CLI

Arguments

Options

Foreground execution

By default, the command runs in the foreground. Its stdout and stderr stream to your terminal in real time, and the CLI exits with the same exit code as the remote command.
CLI

Background execution

Pass -b / --background to start the command and return immediately without waiting for it to finish. The CLI prints the process ID and exits with code 0.
CLI

Piping stdin

You can pipe data into the command through standard input; the CLI streams it to the remote process and signals end-of-file when the input is exhausted, so tools like cat, wc, and grep terminate correctly.
CLI
Piped stdin requires a recent sandbox version. If the sandbox does not support it, the CLI prints a warning and ignores the piped input β€” rebuild your template to pick up the latest sandbox version.

Exit codes and interruption

  • In the foreground, the CLI exits with the remote command’s exit code, so it composes naturally with shell scripts and CI.
  • If the command cannot be started or another error occurs, the CLI prints the error and exits with code 1.
  • Pressing Ctrl+C (or sending a termination signal) kills the remote process before the CLI exits.
Last modified on August 6, 2026