Graceful shutdown overview

Preview

This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

This document gives an overview of the graceful shutdown process inCompute Engine instances. To learn more about the states that an instance cango through during its lifecycle, seeCompute Engine instance lifecycle.

When stopping or deleting an instance, Compute Engine allows ashort timefor the guest OS to fully shut down. If the guest OS doesn't finish runningtasks within this time, then Compute Engine forces a shutdown, which canpotentially lead to data loss or corrupt file systems.

To prevent these issues, you can enable graceful shutdown in an instance. Withthis setting enabled, the guest OS has up to one hour to finish running tasksbefore Compute Engine shuts it down. Graceful shutdown is useful forscenarios when you want to achieve the following:

  • Allowing a high performance computing (HPC) job to fully shut down.

  • Allowing a database to finish submitting active transactions.

  • Allowing an email server to finish processing before shutdown.

  • Allowing a multiplayer game session to finish running.

Important: If you useshutdown scripts withgraceful shutdown, then your scripts run after the graceful shutdown processends. To give your scripts enough time to complete, and avoid potential dataloss or incomplete tasks, we recommend running your scripts during the gracefulshutdown period.

About graceful shutdown

The following sections explain how graceful shutdown works.

Shutdown period

In a compute instance, graceful shutdown is disabled by default. You can enableit when creating or updating an instance. When you enable graceful shutdown, youcan specify a shutdown period as follows:

  • Default period: if you don't specify a shutdown period, thenCompute Engine uses a default period of 10 minutes.

  • Custom period: from one second up to one hour.

We recommend choosing a shutdown period that gives your applications enough timeto finish running tasks. For example, if you estimate that your applicationsneed 10 minutes to finish running tasks, we recommend specifying a 15-minuteshutdown period. This approach prevents tasks from being forcefully stopped andthe potential corruption of data. After all tasks in the guest OS have finishedrunning, you can manually end the graceful shutdown to save costs, as describedin the next section.

Shutdown process

When you stop or delete a compute instance that has graceful shutdown enabled,or if Compute Engine stops or deletes it for a scheduled stop ordeletion, the instance state changes toPENDING_STOP. The graceful shutdownbegins, allowing your applications to finish running their tasks.

Compute Engine ends the graceful shutdown of an instance when thegraceful shutdown period times out, or you manually end the graceful shutdown asfollows:

  • From within the guest OS. You stop the instance using the shutdowncommand of the guest OS; for example,sudo shutdown -h now.

  • From Google Cloud. You stop or delete the instance using one of thefollowing methods:

    • Google Cloud console: complete the following steps:

      1. Go to theVM instances page.

      2. Select the instance, and then clickStop orDelete. If there is noStop orDelete option, clickMore actions >Stop orDelete.

      3. In the dialog that appears, select theSkip graceful shutdown (if applicable) checkbox beforeconfirming to stop or delete the instance.

    • Google Cloud CLI: include the--no-graceful-shutdown flag in thecommand.

    • REST API: include thenoGracefulShutdown=true queryparameter in the request URL.

Caution: Ensure that all tasks in the guest OS have finished running before thegraceful shutdown period times out, or you manually end the graceful shutdown.Otherwise, Compute Engine forcefully stops any running tasks, which canpotentially lead to data loss or corrupt file systems.

When the graceful shutdown process ends, Compute Engine sends theAdvanced Configuration and Power Interface (ACPI) G2 Soft Off signalto the guest OS, sets the instance state toSTOPPING, and then continues withthe stop or delete operation.

Stopping or deleting without graceful shutdown

After you've enabled graceful shutdown in an instance, you can still stop ordelete it without going through the graceful shutdown process. This approachhelps you save costs when, for example, you don't need to gracefully shut downyour instance on a specific day, or if the workload running on the instance haschanged.

To skip graceful shutdown, do one of the following:

Limitations

Graceful shutdown has the following limitations:

  • You can't enable graceful shutdown in the following compute instances:

    • Instances that are part of a managed instance group (MIG).

    • Instances that specify alimited runtime.

  • After you enable graceful shutdown in an instance, you can't do thefollowing:

    • You can't update instance properties thatrequire a restart.

    • If the instance is a TPU VM, then you can't simulate host maintenanceevents.

  • If a graceful shutdown is in progress (PENDING_STOP), then you can't dothe following:

    • You can't update instance properties.

    • If the instance is being deleted, then you can't enable or disabledeletion protection.

  • Your instance doesn't gracefully shut down, or a graceful shutdown isinterrupted, if the following occurs:

    • Your Spot VM or preemptible instance ispreempted.

    • Your instance has ahost maintenance policyset toTERMINATE, and Compute Engine stops the instance for ahost event.

  • You can only gracefully shut down and delete up to 8,000 instances at a timeper project and per region.

  • You can gracefully shut down or modify graceful shutdown settings forinstances created in bulk only after Compute Engine finishescreating all instances.

Pricing

There is no cost to enable or disable graceful shutdown in a compute instance.However, when you stop or delete an instance that has graceful shutdown enabled,you continue to incur charges for the instance as if it was running. Thesecharges stop when the graceful shutdown period ends and the instance statechanges toSTOPPING.

For more detailed pricing information, seeVM instance pricing.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.