> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# anona-compute exec

> Run a command in a sandbox

```text theme={null}
Run a command in a running sandbox and stream its output. anona-compute exits with
the command's exit code. With one argument the command is a shell string
(anona-compute exec ID -- 'ls | wc -l'); several arguments are quoted and joined.

With --json, output is one object per line: {"type":"stdout"|"stderr","data":...}
and finally {"type":"exit","exitCode":N}.
```

## Usage

```text theme={null}
anona-compute exec SANDBOX_ID -- COMMAND [ARGS...] [flags]
```

**Aliases:** `exec`, `ex`

## Flags

| Flag | Type | Description |
| - | - | - |
| `--background`, `-b` | | start the command, print its PID and return |
| `--cmd-timeout` | duration | stop waiting for the command after this long (0 = no limit) |
| `--cwd`, `-w` | string | working directory |
| `--env`, `-e` | stringArray | environment variable KEY=VALUE for the command (repeatable) |
| `--help`, `-h` | | help for exec |
| `--user`, `-u` | string | user to run as (default: the sandbox's default user) |

Global flags (`--api-key`, `--api-url`, `--json`, `--output`, `--profile`, `--request-timeout`, `--verbose`) work on every command; see [anona-compute](https://docs.anonalabs.com/compute/cli/reference/anona-compute.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.