# Sleep and wake

How a VM sleeps, what it keeps while asleep, what wakes it, and which policy to choose.

Source: https://slashinfra.com/docs/how/sleep-and-wake
Last modified: 2026-11-30T16:36:19.000Z

Your VM sleeps when nothing uses it. While it sleeps you pay only for storage: its disk, plus its saved memory if it sleeps in memory. The next request wakes it at the same address, and a VM asleep in memory resumes its programs where they stopped.

Figure: Your VM is billed for CPU and memory only while it's awake, including while an agent waits on its model; asleep, it pays only for storage, and an email wakes it.

## When your VM sleeps

The default policy is `auto`. It checks for activity after 60 seconds without an external request. Requests, typed input, active previews and active jobs keep the VM awake. So does work inside the VM: CPU, disk or network use, a running build or test, and an agent turn that waits for its model. A keystroke in a terminal keeps the VM awake for 5 minutes. An open terminal alone does not.

Output is not work. A spinner or a log does not keep the VM awake. Neither does a connection that carries only keep-alives, below 1 KB a minute.

`auto` knows what common programs look like while they work:

| Program | Counts as work while |
| --- | --- |   
| Coding agents (Claude Code, Codex, opencode) | a turn runs and its model request waits for the answer | 
| Servers, any program with a listening port | a client’s connection moves data | 
| Builds, package managers and `playwright test` | they run | 
| Browsers | the program driving them works; an idle tab does not count | 
| Remote desktop (VNC, noVNC) | a viewer’s connection moves data | 
| Terminal multiplexers (tmux, zellij, screen) | never by themselves; each pane counts by what runs in it | 
| Tunnel daemons (cloudflared, ngrok, Tailscale) | never by themselves; forwarded traffic counts for the server it reaches |

## Two ways to sleep

The state depends on what is still running. A sleep in memory keeps the processes that remain, such as a shell, an agent turn or a server with a port. A sleep on disk applies when no user process remains and no service declares a port.

|  | Sleep in memory | Sleep on disk |
| --- | --- | --- |   
| Kept | Files and process memory | Files and installed packages | 
| The next request | Restores the processes where they stopped | Starts a fresh VM from the saved disk |

A service does not keep the VM awake by itself. A service that declares a port is saved in memory and resumes after the wake.

Either way, CPU and memory stop counting the moment the VM sleeps. While it’s awake they count per second at the VM’s full size, not by load, so an agent waiting on its model costs the same as one compiling. Storage counts all the time: the disk’s allocated bytes, plus the saved memory of a VM that sleeps in memory. [Billing](https://slashinfra.com/docs/how/billing) has the details.

## What survives

Figure: Files survive everything except delete; programs survive only a sleep in memory; open connections always end and clients reconnect.

`si svm stop` ends the processes and keeps the disk. `si svm pause` keeps process memory when a process needs it, and otherwise sleeps on disk.

Open connections always end when the VM sleeps or stops. Browser apps, WebSockets, database clients and agent tools must reconnect, and their next request wakes the VM.

A resumed process can hold stale connections, locks, tokens or timeouts. Write work to files, and make external effects safe to retry.

A background job keeps its log on disk, but its process ends at a sleep on disk. A service starts again after a sleep on disk unless you stopped it. See [services](https://slashinfra.com/docs/platform/services).

## What wakes it

| Activity | Wakes the VM |
| --- | --- |   
| An API request, `si exec`, `si cp` or `si job start` | Yes | 
| A terminal, preview, SSH or port-forward connection | Yes | 
| An accepted inbox message, from email or Telegram | Yes | 
| A due [schedule](https://slashinfra.com/docs/platform/schedules) | Yes | 
| `si svm start` | Yes | 
| A timer or cron job inside the VM | No |

A sleeping VM runs nothing, so a timer or cron job inside it cannot wake it. Work that must run at a set time needs a schedule. A request that the API gateway refuses does not reach the VM and does not wake it.

## Choose a policy

- `auto` is the default. Use it for agents, builds and interactive work. It wakes for a request and sleeps when nothing uses the VM. 
- `timer` sleeps the VM after a set time without external activity, even while a process is busy. Use it when a process should not keep the VM awake, or for a fixed maximum life of a preview or coding session. 
- `on` never sleeps the VM. Use it when the VM must stay reachable, such as for SSH from your [tailnet](https://slashinfra.com/docs/platform/private-network). It uses its memory all the time.

A timer is not a scheduler. A [schedule](https://slashinfra.com/docs/platform/schedules) starts work at a set time. A timer only decides when an idle VM sleeps.

A timer needs the mode and the duration together. `auto` and `on` take no duration. `si svm sleep` needs the VM name every time. It does not use your default VM.

### CLI

```bash
VM=my-vm
si svm sleep "$VM" timer 30m
```

Output

```text
timer 30m
```

### curl

```bash
VM=my-vm
curl -sS -X PUT "https://api.slashinfra.com/svms/$VM/sleep" \
-H "Authorization: Bearer $SI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode":"timer","after_s":1800}'
```

Output

```text
{"mode":"timer","after_s":1800}
```

A running VM applies `auto` or a timer at its next check, and applies `on` at once. A sleeping VM applies `auto` or a timer after its next wake. `on` starts it at once.

## Keep it awake on purpose

`auto` sleeps the VM when none of its work remains. A keep-awake lease counts as work. Hold one for a long command that uses little CPU, for a job that does a little every few seconds, or for a fixed time.

```bash
keep-awake -- npm run build
keep-awake --for 2h
keep-awake on --reason "rendering"
keep-awake off
keep-awake status
```

`keep-awake -- <command>` holds the VM while the command runs and exits with its status. The lock ends with the command, also when the command fails. Tools that call `systemd-inhibit` work unchanged: a `--what` that names `sleep` or `idle` holds the VM for the command.

A lock does not override `timer`. The VM still sleeps at its time.

## Limits

| Setting | Limit |
| --- | --- |   
| Idle check in `auto` | 60 seconds without an external request | 
| Awake after a wake | At least 60 seconds | 
| Request that waits for an external service | At most 15 minutes | 
| `keep-awake` lease | 4 hours unless refreshed | 
| `timer` duration | 30 seconds to 24 hours |

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [Schedules](https://slashinfra.com/docs/platform/schedules): run commands at a set time, while the VM sleeps. 
- [Email](https://slashinfra.com/docs/platform/email): a message wakes the VM and lands on disk. 
- [Isolation](https://slashinfra.com/docs/how/isolation): what a VM can reach while it’s awake.
