TUTORIAL

Long-running Task

Start work with box exec-bg, come back for new output later, and stop it by exec_id when needed.

This page covers the path where one command should keep running after the current terminal closes: a dev server, a watcher, a long test, or a slow import. box exec-bg starts the work, returns an exec_id, and lets you come back later for output or control.

Start one background task

run9 box create runner
run9 box exec-bg runner /bin/sh -lc 'i=1; while [ "$i" -le 6 ]; do echo "tick $i"; i=$((i+1)); sleep 10; done'

The start command returns quickly with the exec_id, current state, deadline information, and the exact pull-output command you can use next.

Read output as it runs

If you want the visible log from the beginning, use --from-start the first time:

run9 box exec-bg pull-output <exec-id> --from-start

Later reads on the same machine can omit --from-start and continue from the saved local cursor, so you only see new output by default:

run9 box exec-bg pull-output <exec-id>
run9 box exec-bg pull-output <exec-id> --wait 20s

--wait 20s is useful when you want the CLI to keep waiting a little longer for the next output window or the final exit event.

Check the durable exec state

When you want the latest state, exit code, or deadlines without rereading the log, inspect the exec directly:

run9 box execs inspect <exec-id>

Stop the task when you are done

If the task is still running and you no longer need it, stop it by exec_id:

run9 box exec-bg kill <exec-id>
run9 box execs inspect <exec-id>

kill is the clean way to end the background task. After that, execs inspect shows the final durable state.