Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Update commit

Vasek Mlejnsky73bfed151268
diff --git a/apps/web/src/app/(docs)/docs/commands/background/page.mdx b/apps/web/src/app/(docs)/docs/commands/background/page.mdx
new file mode 100644
index 000000000..e971fc722
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/commands/background/page.mdx
@@ -0,0 +1,34 @@
+# Running commands in background
+
+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.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/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, // $HighlightLine
+ onStdout: (data) => {
+ console.log(data)
+ },
+})
+
+// Kill the command
+await command.kill()
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+sandbox = Sandbox()
+
+# Start the command in the background
+command = sandbox.commands.run('echo hello; sleep 10; echo world', on_stdout=lambda data: print(data), background=True)
+
+# Kill the command
+command.kill()
+```
+</CodeGroup>
diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx
index fe39d1faf..e5507fe26 100644
--- a/apps/web/src/components/Navigation/routes.tsx
+++ b/apps/web/src/components/Navigation/routes.tsx
@@ -367,18 +367,18 @@ export const routes: NavGroup[] = [
]
},
{
- title: '* Commands',
+ title: 'Commands',
items: [
{
- title: '* Overview',
+ title: 'Overview',
href: '/docs/commands',
},
{
- title: '* Streaming',
+ title: 'Streaming',
href: '/docs/commands/streaming',
},
{
- title: '* Run commands in background',
+ title: 'Run commands in background',
href: '/docs/commands/background',
},
]