> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto-stop timeout

> Limit auto-stop timeout options to control resource usage and costs.

> [!NOTE]
>
> Requires [Core plan](https://ona.com/pricing) or higher.

Limit how long environments can stay idle before auto-stopping. Useful when:

* Controlling cloud infrastructure costs from forgotten environments
* Ensuring resources are available for other team members
* Preventing "never timeout" settings that waste compute

## Configuration

Set the maximum auto-stop timeout to 30 minutes, 1 hour, 3 hours, 8 hours, or No max timeout.

## Effect on users

Users only see auto-stop timeout options up to the policy maximum. For example, with a 3-hour maximum, users can select 30 minutes, 1 hour, or 3 hours.

![Auto-stop timeout options in VS Code](https://mintcdn.com/gitpod-13c83c2b/2OOzw0HWmK9TllJv/images/docs/flex/organizations/vscode-auto-stop-timeout-menu.png?fit=max\&auto=format\&n=2OOzw0HWmK9TllJv\&q=85\&s=1da76f1d44730007736801729a71abe3)

### Set a default auto-stop timeout

> [!NOTE]
>
> Available on the Core plan and higher. [Contact sales](https://ona.com/contact/sales) to learn more.

Each user can choose the auto-stop timeout applied when they create an environment:

1. Open **Account settings**.
2. Under **Preferences**, select a **Default auto-stop timeout**.

The available choices are 30 minutes, 1 hour, 3 hours, 8 hours, and Never. Choices above the organization's maximum auto-stop timeout are not available. If no preference is set, new environments use a 30-minute auto-stop timeout.

Changing this preference affects only environments created afterward. It does not update existing environments. An auto-stop timeout supplied when creating an individual environment overrides the user preference.

Users can also set an environment's auto-stop timeout from the CLI when creating or updating an environment:

```bash theme={null}
ona environment create https://github.com/org/repo --class-id <class-id> --inactivity-timeout 1h
ona environment update <environment-id-or-name> --inactivity-timeout 3h
ona environment update <environment-id-or-name> --inactivity-timeout 0s
```

`0s` requests that auto-stop is disabled. The CLI is subject to the same plan and organization policy limits as the UI.

## When an environment is idle

An environment is **not idle** as long as any of the following are true:

* **Plain SSH session is open**: Any open SSH connection (terminal, SCP, SFTP, tunnels) prevents the environment from going idle, regardless of user interaction. Connection presence alone is enough. Note: VS Code Desktop opens an SSH connection to the environment, but that connection is excluded from activity tracking. VS Code uses its own activity signals instead.
* **VS Code is active (Desktop or Browser)**: The VS Code extension sends activity signals based on keyboard and mouse interaction. After a short period without interaction, VS Code stops signaling and the environment is considered idle.
* **JetBrains Gateway is active**: JetBrains sends activity signals based on keyboard and mouse interaction in the IDE. After approximately 5 minutes without interaction, JetBrains stops signaling and the environment is considered idle.
* **An agent is running**: The environment is not idle while an agent session is executing a task.
* **CLI keep-alive is active**: The `ona environment keep-alive` command prevents idle as long as a watched process is running (see [below](#keep-environment-alive-during-long-running-tasks)).

The following do **not** prevent an environment from going idle:

* Background processes running inside the environment (builds, servers, cron jobs)
* Port forwarding and shared/exposed port traffic (HTTP requests to forwarded ports)
* File system changes
* CPU or memory usage

> [!NOTE]
>
> Activity is tracked in 5-minute intervals. After the configured auto-stop timeout elapses, the environment may take several more minutes to stop. For example, with a 30-minute timeout, if you go idle at 2:00 PM the environment may stop around 2:35 PM.

### Common scenarios

| Scenario | Will it be considered idle? |
| - | - |
| VS Code open, idle (Desktop or Browser) | Yes. VS Code stops sending activity signals after a short period without keyboard or mouse interaction |
| JetBrains open, idle | Yes. JetBrains stops sending activity signals after approximately 5 minutes without keyboard or mouse interaction |
| Editor closed, terminal SSH session open | No. An open SSH connection prevents idle |
| All editor/SSH sessions closed, background build running | Yes. Background processes do not prevent idle |
| Laptop goes to sleep with VS Code open | Depends. If the sleep duration exceeds the configured timeout, the environment may auto-stop before VS Code can resume. JS timers freeze during sleep, so no activity signals are sent until the laptop wakes |
| Laptop goes to sleep with JetBrains open | Yes. JetBrains stops signaling during sleep, so the environment will auto-stop after the configured timeout |

## Keep environment alive during long-running tasks

For long-running tasks like simulations, builds, or data processing that may exceed the timeout, use the CLI `keep-alive` command to prevent automatic shutdown while a process is running.

```bash theme={null}
# Watch an existing process by PID
ona environment keep-alive --pid 1234

# Execute and watch a command
ona environment keep-alive -- python simulation.py

# Run in quiet mode (suppress output except errors)
ona environment keep-alive -q -- ./long-running-script.sh
```

| Flag | Description |
| - | - |
| `--pid` | PID of an existing process to watch |
| `--interval` | Interval between activity signals (default: 5m) |
| `--source` | Source identifier for activity signals |
| `-q, --quiet` | Suppress output except errors |
| `--environment-id` | Environment ID (auto-detected inside environments) |

The command prevents the environment from going idle by sending signals every 5 minutes while the watched process is alive. When the process terminates, the command exits (propagating the exit code if a command was executed).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.