Skip to main content

Start command

The start command specifies a process that runs at the end of the template build — not when a sandbox is created. During the build, E2B executes the start command, waits for the ready command to confirm the process is up, and then takes a snapshot of the entire sandbox including the running process. When you later create a sandbox from that template, the snapshotted process is already running — there is no startup wait. This is how you get servers, seeded databases, or any long-running process available instantly when spawning sandboxes with the SDK.
The start command runs once during template build and is captured in a snapshot. It does not re-execute each time you create a sandbox. If you need to run a command every time a sandbox is created, use sandbox.commands.run() after creating the sandbox instead.This also means that environment variables passed to Sandbox.create() are not available to the start command process — it already ran during the build. If your start command needs environment variables, set them in the template definition using setEnvs() / set_envs().
You can see the full build process here.

Ready command

The ready command determines when the sandbox is ready before a snapshot is created. It is executed in an infinite loop until it returns a successful exit code 0. This lets you control how long the build waits for the start command or any other system state to be ready.

setStartCmd / set_start_cmd

Use setStartCmd / set_start_cmd when you want to run a process during the template build and wait for it to be ready. This method accepts two arguments: the start command and the ready command.
You can also pass a custom shell command as the ready command instead of using a helper:
More examples:

setReadyCmd / set_ready_cmd

Use setReadyCmd / set_ready_cmd when you don’t need a start command but still want to control when the sandbox snapshot is taken. This method accepts only one argument: the ready command. This is useful when your template’s build steps (e.g., runCmd / run_cmd) already start a background process or when you just need extra time for the system to settle before snapshotting.
More examples:

Ready command helpers

The SDK provides helper functions for common ready command patterns. These can be used with both setStartCmd / set_start_cmd and setReadyCmd / set_ready_cmd.