Skip to main content

Documentation Index

Fetch the complete documentation index at: https://e2b.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

To run commands in background, pass the background option to the commands.run() method. This will return immediately and the command will continue to run in the sandbox. You can then later kill the command using the commands.kill() method.
import { Sandbox } from 'e2b'

const sandbox = await Sandbox.create()

// Start the command in the background
const command = await sandbox.commands.run('echo hello; sleep 10; echo world', {
  background: true,
  onStdout: (data) => {
    console.log(data)
  },
})

// Kill the command
await command.kill()