Skip to main content
Exec runs one bounded command inside a running Computer or Sandbox. Use it for short diagnostics, builds that fit the timeout, scripts and verifiable file operations. Use SSH for an interactive Computer shell or a user-managed long-running session. The Console Command area is a sequence of independent executions, not a persistent terminal. Changing directory in one request does not establish a working directory for the next request.

Run from the Console

Select the intended Machine and open Command. Confirm the Machine is running and account eligibility is active. Enter a short command, such as:
Expect Linux in the output. The Console deliberately executes entered shell text through a shell. If you need several related shell actions, combine them in the same submitted command:
The command list is a view of responses in the mounted workspace. It is not a durable command-history or job-recovery service. After an uncertain request, a successful Machine query alone cannot prove whether the command’s side effect occurred.

Run through the SDK

Install the SDK from npm and provide the configured control URL, trusted caller key and intended Computer ID. This complete example prints a deterministic value without modifying the Guest:
Expect Deepest ready, exit code zero, timed_out: false and output_truncated: false. The SDK returns the complete envelope; it does not turn nonzero process exits into automatic retries. For a Sandbox, select the Sandbox by ID and use deepest.sandbox(id).exec(...) with the same request shape. Check the Sandbox’s expiry and idle policy first.

Executable and arguments are separate

The public API does not implicitly interpret shell operators. This request executes a program with arguments:
It should print 5. A string such as "cd /work && npm test" is not an executable name. If shell syntax is actually needed, request a shell explicitly:
Validate untrusted inputs before placing them in a shell program. Prefer separate arguments when possible. No API field sets a persistent working directory for later calls; place the directory change in the same shell invocation. The current request timeout range is 1–900,000 milliseconds. The executable and argument sizes are bounded by the Reference. For Sandbox Exec, the actual budget is additionally capped by its hard expiry and any account entitlement expiry.

Interpret two layers of result

A completed command with exit code 1 is still an observed command result. For example, a test failure is not a network failure. A truncated output may hide diagnostics; do not report a complete transcript. A known timeout does not prove that the command made no changes before timing out. Exec success is no-retry because the command may have effects. Even a seemingly harmless command can invoke network services or write files.

Concurrency and retries

Computer Exec, Sandbox Exec, Tools installation/inspection and Desktop setup share the account’s command capacity. Opening more Machines does not multiply this capacity. EXEC_BUSY uses HTTP 429 and retry: "safe": the request was refused before command dispatch. Wait at least error.retry_after_seconds (the same value as HTTP Retry-After) and explicitly retry the still-needed command. Do not invent a global “requests per minute” quota from this concurrency response. For UNKNOWN / query-first, preserve the command, target ID and relevant task context. Query the original Machine and then inspect the specific intended effect. If a request was supposed to create a file, read that file; if it submitted a third-party action, use that system’s read-only status check. A Machine being running does not resolve the command outcome. There is no public durable Exec ID or command-status endpoint. Do not poll an invented jobs.get() or replay a mutation until its effect is known.

Long-running work

For a Computer job that needs to outlive a single HTTP request, manage the process inside Linux through SSH and an appropriate installed session/process manager. Deepest does not automatically turn Exec into a durable job. Here is a small, user-managed background job with separate output and a completion record. Run this inside the Computer through SSH. It creates a fresh directory rather than overwriting a project. Confirm that the standard nohup utility and Python are available:
Save the printed directory path. You can exit SSH and reconnect to the same Computer; do not Stop it during the job. After the example has had time to finish, inspect the saved directory:
Expect exit code 0, an empty stderr.log, and Verified sum: 5000050000. The launcher PID is diagnostic information, not a durable platform job ID or proof of success. If the completion file is absent or the exit code is nonzero, inspect the logs and the specific intended effect before another submission. Do not assume that a disappeared process never ran. For your own build or script, replace the example task with the authorized workload and use that workload’s output checks. Keep credentials out of command arguments and logs. This pattern does not restart work after Stop or preserve RAM execution state; stronger supervision is a separate Linux configuration you own. Ordinary control-service reconnects may interrupt access without stopping the Guest workload. Stop, however, ends Guest processes. Starting again is a cold boot; only services configured to start on boot restart under their own Linux configuration. A foreground Sandbox Exec prevents idle cleanup during that execution and refreshes activity, but it never extends the fixed 24-hour lifetime. A detached background process alone does not refresh Sandbox idle activity.

Troubleshoot and finish

When finished, retain required files and explicitly Stop an otherwise unused Machine. Stopping frees running Memory but not Storage. For exact schemas and error codes, use API Reference, errors and reliability.