# Idle shutdown

Colab Enterprise runtimes shut down after 180 minutes of
inactivity by default. This page describes the idle shutdown feature and how to
change the default idle shutdown settings or turn the feature off
when you create a runtime template.

## Overview

To help manage costs, Colab Enterprise runtimes
shut down after being idle for a specific time period by default.
You can change the amount of time or turn this feature off when you create a
runtime template.

After you create a runtime template, its configuration can't be changed.
Therefore, you can't change a runtime or runtime template's
idle shutdown settings. To use a runtime with different idle shutdown settings,
you must create a runtime template with the settings that you want, and then
use a runtime generated from that runtime template.

## Before you begin

### Required roles


To get the permissions that
you need to create a runtime in Colab Enterprise,

ask your administrator to grant you the
Colab Enterprise Admin ([`roles/aiplatform.colabEnterpriseAdmin`](https://docs.cloud.google.com/gemini-enterprise-agent-platform/machine-learning/general/access-control.md.txt#aiplatform.colabEnterpriseAdmin))
IAM role on the project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).
One or more of the required roles includes the `dataform.repositories.list` permission. Users who are granted the `dataform.repositories.list` permission or the [Code Creator
(`roles/dataform.codeCreator`)](https://docs.cloud.google.com/dataform/docs/access-control#dataform.codeCreator) role in a project can list the names of code assets in that project by using the Dataform API or the Dataform command-line interface (CLI). Non-administrators using BigQuery Studio can only see code assets that they created or that were shared with them.

## Create a runtime template with specific idle shutdown settings

To create a runtime template with specific idle shutdown settings, you can
use the Google Cloud console or the Google Cloud CLI.

### Console

To create a runtime template with specific idle shutdown settings:

1. In the Google Cloud console, go to
   the Colab Enterprise **Runtime templates** page.

   [Go to Runtime templates](https://console.cloud.google.com/agent-platform/colab/runtime-templates)
2. Click **New
   template**.

   The **Create new runtime template** dialog appears.
3. In the **Runtime basics** section, enter
   a **Display name**.

4. In the **Region** menu, select the region where you want
   your runtime template.

5. To change the idle shutdown settings, click the
   **Configure compute** section, and complete the
   following step.

6. In the **Idle shutdown** section:

   - To turn off idle shutdown, clear
     **Enable idle shutdown**.

   - To change the inactivity time period, in
     **Time of inactivity before shutdown (Minutes)**,
     change the number to the number of minutes of inactivity that
     you want. In the Google Cloud console, this setting can be set
     to any integer value from 10 to 1440.

7. In the **Environment** section, select an **Environment** .
   The default is **Latest** (currently Python 3.13).

8. Optional: In the **Post-startup script** field, enter the URI for a
   post-startup script. For more information about using a post-startup script, see
   [Use a post-startup script](https://docs.cloud.google.com/colab/docs/post-startup-script.md.txt).

9. Optional: Under the post-startup script URL, select your post-startup script's behavior. The
   default behavior is **Run once** . For more information, see
   [Post-startup script behavior](https://docs.cloud.google.com/colab/docs/post-startup-script.md.txt#behavior).

10. Optional: To add an environment variable, click
    **Add env variable** ,
    and then enter a **Key** and **Value** pair.
    To add more environment variables, repeat this step.

11. Click **Continue**.

12. Complete the rest of the creation dialog.

13. Click **Create** to finish creating the runtime template.

    Your runtime template appears in the list on
    the **Runtime templates** tab.

### gcloud


Before using any of the command data below,
make the following replacements:

- `DISPLAY_NAME`: the display name of your runtime template.
- `INACTIVITY_DURATION`: the duration of inactivity before the runtime shuts down. An input of `0s` turns off the idle shutdown feature. The valid range of values is from 10 minutes (`10m`) to 24 hours (`24h`).
- `PROJECT_ID`: your project ID.
- `REGION`: the region where you want your runtime template.


Execute the

following

command:

#### Linux, macOS, or Cloud Shell

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud colab runtime-templates create --display-name=DISPLAY_NAME \
    --idle-shutdown-timeout=INACTIVITY_DURATION \
    --project=PROJECT_ID \
    --region=REGION
```

#### Windows (PowerShell)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud colab runtime-templates create --display-name=DISPLAY_NAME `
    --idle-shutdown-timeout=INACTIVITY_DURATION `
    --project=PROJECT_ID `
    --region=REGION
```

#### Windows (cmd.exe)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [gcloud init](https://docs.cloud.google.com/sdk/gcloud/reference/init); or [gcloud auth login](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud colab runtime-templates create --display-name=DISPLAY_NAME ^
    --idle-shutdown-timeout=INACTIVITY_DURATION ^
    --project=PROJECT_ID ^
    --region=REGION
```

For more information about the command for creating a
runtime template from the command line, see the [gcloud CLI
documentation](https://docs.cloud.google.com/sdk/gcloud/reference/colab/runtime-templates/create).


<br />

## How idle shutdown works

Your runtime shuts down when the following conditions are met:

- There's no kernel activity for the specified time period.

- The runtime isn't connected to a notebook.

To disconnect a runtime from a notebook, close the notebook. Leaving a
notebook open while connected to a runtime prevents the runtime
from shutting down.

For information on charges generated by runtimes, see
[Runtime charges](https://docs.cloud.google.com/colab/docs/runtimes.md.txt#runtime-charges).

## What's next

- Learn more about [runtimes and runtime templates](https://docs.cloud.google.com/colab/docs/runtimes.md.txt).
- Learn how to [create a runtime](https://docs.cloud.google.com/colab/docs/create-runtime.md.txt) based on a runtime template.
- To find a notebook that can help you get your project started quickly, see the [notebook gallery](https://console.cloud.google.com/agent-platform/colab/notebook-gallery).