---
title: microvm keepalive
description: Keep a running MicroVM awake while work runs inside it, by polling its health
---

## 1. Synopsis

Keep a running MicroVM awake while work runs inside it, by polling its health

```sh
microvm keepalive [options]
```

## 2. Parameters

| Parameter | Kind | Type | Required | Default | Choices | Help |
| --- | --- | --- | --- | --- | --- | --- |
| `--interval` | flag | `string` | no | none | any | Seconds between health polls. Default: a third of the idle window, at most 20 |
| `--while-busy` | flag | `boolean` | no | none | any | Stop once the daemon reports no running exec |
| `--for` | flag | `string` | no | none | any | Stop after this many seconds, busy or not |
| `--idle-window` | flag | `string` | no | none | any | The VM's `maxIdleDurationSeconds`. Read from the control plane when omitted |
| `--tolerated-errors` | flag | `string` | no | `3` | any | Retryable poll failures in a row to retry, a second apart, before giving up |
| `--endpoint` | flag | `string` | no | none | any | The VM's endpoint, as reported by `run` |
| `--agent-token` | flag | `string` | no | none | any | The agent token delivered to the VM at launch. Prefer `--name` or `--agent-token-file` |
| `--agent-token-file` | flag | `path` | no | none | any | Read the agent token from a protected file, or from stdin with `-`. On Unix, the file must grant no permissions to group or other users |
| `--microvm-id` | flag | `string` | no | none | any | The MicroVM id, needed to mint the endpoint proxy token |
| `--name` | flag | `string` | no | none | any | The name `run --keep --vm-name` registered, standing in for the whole triple |
| `--port` | flag | `string` | no | none | any | The daemon's port inside the guest |
| `--state-dir` | flag | `path` | no | none | any | Where the local state lives — the name registry, and exec's per-VM history. Defaults to $MICROVM\_STATE\_DIR or ~/.microvm/runs |
| `--region` | flag | `string` | no | none | any | AWS region. Defaults to $AWS\_REGION, then $AWS\_DEFAULT\_REGION, then us-east-1 |
| `--unlisted-region` | flag | `string` | no | none | any | Deprecated since 1.3.0: `--region` takes any region name |

The 3 global flags (`--json`, `--dense`, `--quiet`) are accepted here as on every command, and are left out of the table above for that reason; see [Global flags](/microvms-agentd/reference/#3-global-flags).

## 3. Response

On success stdout carries one envelope whose `type` is `microvm.keepalive`. Its `data` object carries these keys: `microvmId`, `end`, `polls`, `lastBusy`, `elapsedSec`, `intervalSec`, `idleWindowSec`.

[The envelope](/microvms-agentd/reference/envelope/) describes the fields around `data`. [Response types](/microvms-agentd/reference/response-types/) lists every `type` the CLI emits and which commands share each one.

## 4. Failures

A failure exits with one of the statuses on [Exit codes](/microvms-agentd/reference/exit-codes/) and writes the error shape on [The envelope](/microvms-agentd/reference/envelope/): a stable `code` to branch on, an `exitCode` that matches the process status, a human-readable `error`, and `suggestions`.

Where a failure is one this project has measured on the platform, the envelope's `finding` names the section of the platform notes that documents it. The exit-code table links each one.

## 5. Provenance

This page is generated from `docs/manifest.json`, the output of `microvm manifest`, which the CLI derives from its own argument tree. This page reads the `keepalive` entry of `data.commands`. `site/scripts/gen-reference.mjs` writes it into the site's content directory on every `pnpm run sync`, so an edit made here is overwritten by the next run.

To change the page, change the source. Regenerate the source with `mise run manifest` from the repository root; `mise run manifest:check` fails when the committed file no longer matches what the binary emits.