# Template Readycmd (/v2.29.1/template-readycmd)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1068 · updated: 2026-07-30 -->
Related: [Errors](/v2.29.1/errors.md), [Sandbox](/v2.29.1/sandbox.md), [Sandbox Commands](/v2.29.1/sandbox-commands.md), [Sandbox Filesystem](/v2.29.1/sandbox-filesystem.md), [Template](/v2.29.1/template.md), [Template Logger](/v2.29.1/template-logger.md)

### ReadyCmd [#readycmd]

Class for ready check commands.

#### Constructors [#constructors]

```ts
new ReadyCmd(cmd: string): ReadyCmd
```

###### Parameters [#parameters]

| Parameter | Type     |
| --------- | -------- |
| `cmd`     | `string` |

###### Returns [#returns]

`ReadyCmd`

#### Methods [#methods]

### getCmd() [#getcmd]

```ts
getCmd(): string
```

###### Returns [#returns-1]

`string`

## Functions [#functions]

### waitForFile() [#waitforfile]

```ts
function waitForFile(filename: string): ReadyCmd
```

Wait for a file to exist.
Uses shell test command to check file existence.

#### Parameters [#parameters-1]

| Parameter  | Type     | Description                  |
| ---------- | -------- | ---------------------------- |
| `filename` | `string` | Path to the file to wait for |

#### Returns [#returns-2]

`ReadyCmd`

ReadyCmd that checks for the file

#### Example [#example]

```ts
import { Template, waitForFile } from 'e2b'

const template = Template()
  .fromBaseImage()
  .setStartCmd('./init.sh', waitForFile('/tmp/ready'))
```

***

### waitForPort() [#waitforport]

```ts
function waitForPort(port: number): ReadyCmd
```

Wait for a port to be listening.
Uses `ss` command to check if a port is open and listening.

#### Parameters [#parameters-2]

| Parameter | Type     | Description             |
| --------- | -------- | ----------------------- |
| `port`    | `number` | Port number to wait for |

#### Returns [#returns-3]

`ReadyCmd`

ReadyCmd that checks for the port

#### Example [#example-1]

```ts
import { Template, waitForPort } from 'e2b'

const template = Template()
  .fromPythonImage()
  .setStartCmd('python -m http.server 8000', waitForPort(8000))
```

***

### waitForProcess() [#waitforprocess]

```ts
function waitForProcess(processName: string): ReadyCmd
```

Wait for a process with a specific name to be running.
Uses `pgrep` to check if a process exists.

#### Parameters [#parameters-3]

| Parameter     | Type     | Description                     |
| ------------- | -------- | ------------------------------- |
| `processName` | `string` | Name of the process to wait for |

#### Returns [#returns-4]

`ReadyCmd`

ReadyCmd that checks for the process

#### Example [#example-2]

```ts
import { Template, waitForProcess } from 'e2b'

const template = Template()
  .fromBaseImage()
  .setStartCmd('./my-daemon', waitForProcess('my-daemon'))
```

***

### waitForTimeout() [#waitfortimeout]

```ts
function waitForTimeout(timeout: number): ReadyCmd
```

Wait for a specified timeout before considering the sandbox ready.
Uses `sleep` command to wait for a fixed duration.

#### Parameters [#parameters-4]

| Parameter | Type     | Description                                               |
| --------- | -------- | --------------------------------------------------------- |
| `timeout` | `number` | Time to wait in milliseconds (minimum: 1000ms / 1 second) |

#### Returns [#returns-5]

`ReadyCmd`

ReadyCmd that waits for the specified duration

#### Example [#example-3]

```ts
import { Template, waitForTimeout } from 'e2b'

const template = Template()
  .fromNodeImage()
  .setStartCmd('npm start', waitForTimeout(5000)) // Wait 5 seconds
```

***

### waitForURL() [#waitforurl]

```ts
function waitForURL(url: string, statusCode: number): ReadyCmd
```

Wait for a URL to return a specific HTTP status code.
Uses `curl` to make HTTP requests and check the response status.

#### Parameters [#parameters-5]

| Parameter    | Type     | Default value | Description                                                                         |
| ------------ | -------- | ------------- | ----------------------------------------------------------------------------------- |
| `url`        | `string` | `undefined`   | URL to check (e.g., '[http://localhost:3000/health](http://localhost:3000/health)') |
| `statusCode` | `number` | `200`         | Expected HTTP status code (default: 200)                                            |

#### Returns [#returns-6]

`ReadyCmd`

ReadyCmd that checks the URL

#### Example [#example-4]

```ts
import { Template, waitForURL } from 'e2b'

const template = Template()
  .fromNodeImage()
  .setStartCmd('npm start', waitForURL('http://localhost:3000/health'))
```
