Skip to main content
Commands can be run in the background by passing the background option to commands.run(). This returns immediately and the command continues running in the sandbox. You can later kill it with commands.kill().
import { Sandbox } from 'novita-sandbox/code-interpreter'

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()

await sandbox.kill()
Last modified on June 4, 2026