Skip to main content

Execute commands

Put exec options before the VM name. Everything after the name is the remote command. -- makes the boundary explicit. Arguments are literal; use sh -c or bash -lc for shell variables, pipes, and redirection. Foreground execution streams stdout and stderr and returns the command’s exit status. --timeout sets a command deadline in seconds; 0, the default, waits indefinitely. This deadline is separate from the VM’s idle TTL.
Noninteractive stdin is forwarded to the command. JSON execution returns the VM ID, current container ID, PID, exit code, stdout, and stderr instead of streaming output.

Processes in Python

process.exec() returns a handle immediately. Supply text, bytes, or a binary file as stdin; SDK input is uploaded before execution and followed by EOF. Use SSH for an interactive terminal. For live logs:
Stream reads consume output. process.wait(timeout=30) bounds how long the caller waits; it does not itself kill the command. Use process.kill() to cancel it. See process management for run_code, environment overrides, process handles, and async behavior. The same process API is available through vm.process and vm.aio.process.

Detached commands and logs

Save the PID and container ID returned by detached JSON execution. --container-id prevents killing a reused PID after the VM has restarted. Managed process handles belong to the current runtime; use a systemd unit for a service that must start again after a cold boot. Use only one log selector at a time: --pid, --unit, or --session. Without a selector, logs reads the systemd journal. Detached work does not maintain an idle lease after the CLI exits; disable the TTL for unattended jobs.

SSH and browser terminal

SSH connects as root through an authenticated Beam tunnel. You do not need to expose an SSH port publicly. The CLI manages a local Ed25519 identity and known-host records; your private key stays on your machine. Install local OpenSSH (ssh, ssh-keygen, and scp) to use these commands. The browser terminal uses port 7681. terminal opens your browser; --url prints the entry URL instead. Protect browser access as described in networking.

Copy and sync files

SCP requires exactly one remote NAME:/path argument. Quote paths with spaces. Sync uploads the local directory’s contents to /workspace/, excludes .git, and can watch for local changes. Install rsync locally to use sync; it is installed in the prepared VM image. Sync is an upload operation, not bidirectional synchronization, and does not delete remote files absent locally.

Systemd services

VMs boot systemd and support your own units. For example, create a service that starts a web server on every cold boot:
Inspect its state and journal:
The unit file and enabled state persist. Stop/start cold-boots and starts enabled units; pause/resume restores the running process state.

Coding agents

Prepared VM images include Claude Code and Codex CLIs. Configure the selected agent’s authentication or provider credentials inside the VM; beam vm prompt does not supply an agent subscription or API key.
Background mode returns a prompt-... session ID and starts a systemd transient unit. Read its durable output with:
Session log files live at /workspace/.beam-vm/logs/. Those files survive stop/start; an agent launched as a transient unit does not automatically rerun after a cold boot.

Metrics

vm.metrics() samples guest CPU, memory, and root-disk usage over one second. It counts as activity and can wake a VM with automatic resume enabled. It is a current sample, not historical billing data; use the dashboard Usage page for costs.