You have a command, such as a test, a build step, or a script an agent just wrote, and you want it to run on a clean remote machine instead of your laptop. box exec runs it in a box, streams the output to your terminal, and hands back the exit code.
Run one command
sys9 run box create work
sys9 run box exec work uname -a
The box wakes for the command. When it is idle, run9 can let it sleep. There is no manual start step.
Reuse the same box
sys9 run box exec work mkdir -p /work/app
sys9 run box exec work ls -ld /work /work/app
sys9 run box exec work find /work -maxdepth 1 -mindepth 1 -type d
Each command sees the same box file system, so later commands can use what earlier commands created.
But each box exec is still a fresh process. Working directory changes, shell variables, and aliases do not carry over from one exec to the next.
Set the directory or a variable for one command
If you only need one different working directory or one extra env var, keep it as one exec instead of wrapping the command in sh -lc 'cd ... && export ... && ...':
sys9 run box exec work --workdir /work/app git status
sys9 run box exec work -e NODE_ENV=test printenv NODE_ENV
Use --workdir for “run this command from that directory.” Use -e KEY=VALUE for “run this command with one extra env var.” Reach for a shell only when the job actually needs shell syntax or several manual steps.
Alternative paths
If the job grows beyond one command, or you simply prefer another client, these pages cover the same box from a different angle:
- Keep a Task Running keeps one command running after you close the current terminal, then lets you come back by
exec_id. - Open a Shell keeps you inside one shell session so
cd, shell variables, and trial-and-error work all stay in one place. - Connect with SSH reaches the same box through a standard
sshclient.
Those paths are usually clearer than packing package installs, file edits, cd, export, here-docs, pipes, and redirections into one long shell string.
Stopping the box
For day-to-day work, you usually do not stop the box. Use box stop to end current work and release compute immediately while retaining files. Forking the box does not need a stop either.
sys9 run box stop work