[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-19 (世界標準時間)。"],[[["\u003cp\u003eGraceful shutdown allows Compute Engine instances up to one hour to complete tasks before shutting down, preventing potential data loss or file corruption.\u003c/p\u003e\n"],["\u003cp\u003eYou can enable graceful shutdown on an instance when creating or updating it, specifying a custom shutdown period from one second up to one hour, or using the default 10-minute period.\u003c/p\u003e\n"],["\u003cp\u003eDuring a graceful shutdown, the instance enters a \u003ccode\u003ePENDING_STOP\u003c/code\u003e state, and the shutdown process can be manually ended either from within the guest OS or through the Google Cloud console, CLI, or REST API.\u003c/p\u003e\n"],["\u003cp\u003eGraceful shutdown can be skipped for single operations or disabled entirely, offering flexibility in managing instance shutdowns based on workload needs.\u003c/p\u003e\n"],["\u003cp\u003eGraceful shutdown is subject to limitations, such as not being available for managed instance groups (MIGs) or instances with limited runtime, and incurs charges until the shutdown period ends.\u003c/p\u003e\n"]]],[],null,["# Graceful shutdown overview\n\n*** ** * ** ***\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document gives an overview of the graceful shutdown process in\nCompute Engine instances. To learn more about the states that an instance can\ngo through during its lifecycle, see\n[Compute Engine instance lifecycle](/compute/docs/instances/instance-lifecycle).\n\nWhen stopping or deleting an instance, Compute Engine allows a\n[short time](/compute/docs/instances/suspend-stop-reset-instances-overview#stopping-instance)\nfor the guest OS to fully shut down. If the guest OS doesn't finish running\ntasks within this time, then Compute Engine forces a shutdown, which can\npotentially lead to data loss or corrupt file systems.\n\nTo prevent these issues, you can enable graceful shutdown in an instance. With\nthis setting enabled, the guest OS has up to one hour to finish running tasks\nbefore Compute Engine shuts it down. Graceful shutdown is useful for\nscenarios when you want to achieve the following:\n\n- Allowing a high performance computing (HPC) job to fully shut down.\n\n- Allowing a database to finish submitting active transactions.\n\n- Allowing an email server to finish processing before shutdown.\n\n- Allowing a multiplayer game session to finish running.\n\n| **Important:** If you use [shutdown scripts](/compute/docs/shutdownscript) with graceful shutdown, then your scripts run after the graceful shutdown process ends. To give your scripts enough time to complete, and avoid potential data loss or incomplete tasks, we recommend running your scripts during the graceful shutdown period.\n\nAbout graceful shutdown\n-----------------------\n\nThe following sections explain how graceful shutdown works.\n\n### Shutdown period\n\nIn a compute instance, graceful shutdown is disabled by default. You can enable\nit when creating or updating an instance. When you enable graceful shutdown, you\ncan specify a shutdown period as follows:\n\n- **Default period**: if you don't specify a shutdown period, then\n Compute Engine uses a default period of 10 minutes.\n\n- **Custom period**: from one second up to one hour.\n\nWe recommend choosing a shutdown period that gives your applications enough time\nto finish running tasks. For example, if you estimate that your applications\nneed 10 minutes to finish running tasks, we recommend specifying a 15-minute\nshutdown period. This approach prevents tasks from being forcefully stopped and\nthe potential corruption of data. After all tasks in the guest OS have finished\nrunning, you can manually end the graceful shutdown to save costs, as described\nin the next section.\n\n### Shutdown process\n\nWhen you stop or delete a compute instance that has graceful shutdown enabled,\nor if Compute Engine stops or deletes it for a scheduled stop or\ndeletion, the instance state changes to `PENDING_STOP`. The graceful shutdown\nbegins, allowing your applications to finish running their tasks.\n\nCompute Engine ends the graceful shutdown of an instance when the\ngraceful shutdown period times out, or you manually end the graceful shutdown as\nfollows:\n\n- **From within the guest OS** . You stop the instance using the shutdown\n command of the guest OS; for example, `sudo shutdown -h now`.\n\n- **From Google Cloud**. You stop or delete the instance using one of the\n following methods:\n\n - **Google Cloud console**: complete the following steps:\n\n 1. Go to the **VM instances** page.\n\n 2. Select the instance, and then click\n stop **Stop** or\n delete **Delete** . If there is\n no **Stop** or **Delete** option, click\n more_vert **More actions \\\u003e**\n stop **Stop** or\n delete **Delete**.\n\n 3. In the dialog that appears, select the\n **Skip graceful shutdown (if applicable)** checkbox before\n confirming to stop or delete the instance.\n\n - **Google Cloud CLI** : include the `--no-graceful-shutdown` flag in the\n command.\n\n - **REST API** : include the `noGracefulShutdown=true` query\n parameter in the request URL.\n\n| **Caution:** Ensure that all tasks in the guest OS have finished running before the graceful shutdown period times out, or you manually end the graceful shutdown. Otherwise, Compute Engine forcefully stops any running tasks, which can potentially lead to data loss or corrupt file systems.\n\nWhen the graceful shutdown process ends, Compute Engine sends the\n[Advanced Configuration and Power Interface (ACPI) G2 Soft Off signal](https://en.wikipedia.org/wiki/ACPI#Global_states)\nto the guest OS, sets the instance state to `STOPPING`, and then continues with\nthe stop or delete operation.\n\n### Stopping or deleting without graceful shutdown\n\nAfter you've enabled graceful shutdown in an instance, you can still stop or\ndelete it without going through the graceful shutdown process. This approach\nhelps you save costs when, for example, you don't need to gracefully shut down\nyour instance on a specific day, or if the workload running on the instance has\nchanged.\n\nTo skip graceful shutdown, do one of the following:\n\n- **Skip graceful shutdown for single operations** . Keep graceful shutdown\n enabled, but bypass it for specific stop or delete operations. To do this,\n follow the [manual shutdown process](#process).\n\n- **Disable graceful shutdown entirely** . If you no longer need to gracefully\n shut down an instance, then you can disable this feature. For more\n information, see\n [Disable graceful shutdown in a Compute Engine instance](/compute/docs/instances/disable-graceful-shutdown).\n\nLimitations\n-----------\n\nGraceful shutdown has the following limitations:\n\n- You can't enable graceful shutdown in the following compute instances:\n\n - Instances that are part of a managed instance group (MIG).\n\n - Instances that specify a\n [limited runtime](/compute/docs/instances/limit-vm-runtime).\n\n- After you enable graceful shutdown in an instance, you can't do the\n following:\n\n - You can't update instance properties that\n [require a restart](/compute/docs/instances/update-instance-properties#updatable-properties).\n\n - If the instance is a TPU VM, then you can't simulate host maintenance\n events.\n\n- If a graceful shutdown is in progress (`PENDING_STOP`), then you can't do\n the following:\n\n - You can't update instance properties.\n\n - If the instance is being deleted, then you can't enable or disable\n [deletion protection](/compute/docs/instances/preventing-accidental-vm-deletion).\n\n- Your instance doesn't gracefully shut down, or a graceful shutdown is\n interrupted, if the following occurs:\n\n - Your Spot VM or preemptible instance is\n [preempted](/compute/docs/instances/preemptible#preemption-process).\n\n - Your instance has a\n [host maintenance policy](/compute/docs/instances/setting-vm-host-options#available_host_maintenance_properties)\n set to `TERMINATE`, and Compute Engine stops the instance for a\n host event.\n\n- You can only gracefully shut down and delete up to 8,000 instances at a time\n per project and per region.\n\n- You can gracefully shut down or modify graceful shutdown settings for\n instances created in bulk only after Compute Engine finishes\n creating all instances.\n\nPricing\n-------\n\nThere is no cost to enable or disable graceful shutdown in a compute instance.\nHowever, when you stop or delete an instance that has graceful shutdown enabled,\nyou continue to incur charges for the instance as if it was running. These\ncharges stop when the graceful shutdown period ends and the instance state\nchanges to `STOPPING`.\n\nFor more detailed pricing information, see\n[VM instance pricing](/compute/vm-instance-pricing).\n\nWhat's next\n-----------\n\n- [Enable graceful shutdown in a Compute Engine instance](/compute/docs/instances/enable-graceful-shutdown)\n\n- [View graceful shutdown in a Compute Engine instance](/compute/docs/instances/view-graceful-shutdown)"]]