gcloud compute instances set-scheduling Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud compute instances set-scheduling - set scheduling options for Compute Engine virtual machines
- SYNOPSIS
gcloud compute instances set-scheduling
INSTANCE_NAME
[--clear-min-node-cpu
][--host-error-timeout-seconds
=HOST_ERROR_TIMEOUT_SECONDS
][--local-ssd-recovery-timeout
=LOCAL_SSD_RECOVERY_TIMEOUT
][--maintenance-policy
=MAINTENANCE_POLICY
][--min-node-cpu
=MIN_NODE_CPU
][--[no-]preemptible
][--provisioning-model
=PROVISIONING_MODEL
][--[no-]restart-on-failure
][--zone
=ZONE
][--clear-discard-local-ssds-at-termination-timestamp
|--discard-local-ssds-at-termination-timestamp
=DISCARD_LOCAL_SSDS_AT_TERMINATION_TIMESTAMP
][--clear-instance-termination-action
|--instance-termination-action
=INSTANCE_TERMINATION_ACTION
][--clear-max-run-duration
|--max-run-duration
=MAX_RUN_DURATION
][--clear-node-affinities
|--node
=NODE
|--node-affinity-file
=PATH_TO_FILE
|--node-group
=NODE_GROUP
][--clear-termination-time
|--termination-time
=TERMINATION_TIME
][GCLOUD_WIDE_FLAG …
]
- DESCRIPTION
$gcloud compute instances set-scheduling
is used to updatescheduling options for VM instances. You can only call this method on a VMinstance that is stopped (a VM instance in aTERMINATED
state).- EXAMPLES
- To set instance to be terminated during maintenance, run:
gcloudcomputeinstancesset-schedulingexample-instance--maintenance-policy=TERMINATE--zone=us-central1-b
- POSITIONAL ARGUMENTS
INSTANCE_NAME
- Name of the instance to operate on. For details on valid instance names, referto the criteria documented under the field 'name' at:https://cloud.google.com/compute/docs/reference/rest/v1/instances
- FLAGS
--clear-min-node-cpu
- Removes the min-node-cpu field from the instance. If specified, the instancemin-node-cpu will be cleared. The instance will not be overcommitted and utilizethe full CPU count assigned.
--host-error-timeout-seconds
=HOST_ERROR_TIMEOUT_SECONDS
- The timeout in seconds for host error detection. The value must be set with 30second increments, with a range of 90 to 330 seconds. If unset, the defaultbehavior of the host error recovery is used.
--local-ssd-recovery-timeout
=LOCAL_SSD_RECOVERY_TIMEOUT
- Specifies the maximum amount of time a Local Ssd Vm should wait while recoveryof the Local Ssd state is attempted. Its value should be in between 0 and 168hours with hour granularity and the default value being 1 hour.
--maintenance-policy
=MAINTENANCE_POLICY
- Specifies the behavior of the VMs when their host machines undergo maintenance.The default is MIGRATE. For more information, seehttps://cloud.google.com/compute/docs/instances/host-maintenance-options.
MAINTENANCE_POLICY
must be one of:MIGRATE
- The instances should be migrated to a new host. This will temporarily impact theperformance of instances during a migration event.
TERMINATE
- The instances should be terminated.
--min-node-cpu
=MIN_NODE_CPU
- Minimum number of virtual CPUs this instance will consume when running on asole-tenant node.
--[no-]preemptible
- If provided, instances will be preemptible and time-limited. Instances might bepreempted to free up resources for standard VM instances, and will only be ableto run for a limited amount of time. Preemptible instances can not be restartedand will not migrate. Use
--preemptible
to enable and--no-preemptible
to disable. --provisioning-model
=PROVISIONING_MODEL
- Specifies the provisioning model for your VM instances. This choice affects theprice, availability, and how long your VM instances can run.
PROVISIONING_MODEL
must be one of:RESERVATION_BOUND
- The VM instances run for the entire duration of their associated reservation.You can only specify this provisioning model if you want your VM instances toconsume a specific reservation with either a calendar reservation mode or adense deployment type.
SPOT
- Compute Engine may stop a Spot VM instance whenever it needs capacity. BecauseSpot VM instances don't have a guaranteed runtime, they come at a discountedprice.
STANDARD
- The default option. The STANDARD provisioning model gives you full control overyour VM instances' runtime.
--[no-]restart-on-failure
- The instances will be restarted if they are terminated by Compute Engine. Thisdoes not affect terminations performed by the user. This option is mutuallyexclusive with --preemptible. Use
--restart-on-failure
to enableand--no-restart-on-failure
to disable. --zone
=ZONE
- Zone of the instance to operate on. If not specified, you might be prompted toselect a zone (interactive mode only).
gcloud
attempts to identify theappropriate zone by searching for resources in your currently active project. Ifthe zone cannot be determined,gcloud
prompts you for a selection withall available Google Cloud Platform zones.To avoid prompting when this flag is omitted, the user can set the
property:compute/zone
gcloudconfigsetcompute/zoneZONE
A list of zones can be fetched by running:
gcloudcomputezoneslist
To unset the property, run:
gcloudconfigunsetcompute/zone
Alternatively, the zone can be stored in the environment variable
.CLOUDSDK_COMPUTE_ZONE
- Discard Local SSDs At Termination Timestamp
At most one of these can be specified:
--clear-discard-local-ssds-at-termination-timestamp
- Removes the discard-local-ssds-at-termination-timestamp field from thescheduling options.
--discard-local-ssds-at-termination-timestamp
=DISCARD_LOCAL_SSDS_AT_TERMINATION_TIMESTAMP
- Required to be set to
true
and only allowed for VMs that have oneor more local SSDs, use --instance-termination-action=STOP, and use either--max-run-duration or --termination-time.This flag indicates the value that you want Compute Engine to use for the
--discard-local-ssd
flag in the automaticgcloud compute instancesstop
command. This flag only supports thetrue
value,which discards local SSD data when automatically stopping this VM during itsterminationTimestamp
.For more information about the
--discard-local-ssd
flag, seehttps://cloud.google.com/compute/docs/disks/local-ssd#stop_instance.
- Instance Termination Action
At most one of these can be specified:
--clear-instance-termination-action
- Disables the termination action for this VM if allowed OR sets terminationaction to the default value. Depending on a VM's availability settings, atermination action is either required or not allowed. This flag is required whenyou are updating a VM such that it's previously specified termination action isno longer allowed. If you use this flag when a VM requires a termination action,it's termination action is just set to the default value (stop).
--instance-termination-action
=INSTANCE_TERMINATION_ACTION
- Specifies the termination action that will be taken upon VM preemption(--provisioning-model=SPOT) or automatic instance termination(--max-run-duration or --termination-time).
INSTANCE_TERMINATION_ACTION
must be one of:DELETE
- Permanently delete the VM.
STOP
- Default only for Spot VMs. Stop the VM without preserving memory. The VM can berestarted later.
- Max Run Duration
At most one of these can be specified:
--clear-max-run-duration
- Removes the max-run-duration field from the scheduling options.
--max-run-duration
=MAX_RUN_DURATION
- Limits how long this VM instance can run, specified as a duration relative tothe last time when the VM began running. Format the duration, MAX_RUN_DURATION,as the number of days, hours, minutes, and seconds followed by d, h, m, and srespectively. For example, specify
30m
for a duration of 30 minutesor specify1d2h3m4s
for a duration of 1 day, 2 hours, 3 minutes,and 4 seconds. Alternatively, to specify a timestamp, use --termination-timeinstead.If neither --max-run-duration nor --termination-time is specified (default), theVM instance runs until prompted by a user action or system event. If either isspecified, the VM instance is scheduled to be automatically terminated at theVM's termination timestamp (
terminationTimestamp
) using the actionspecified by --instance-termination-action.Note: The
terminationTimestamp
is removed whenever the VM isstopped or suspended and redefined whenever the VM is rerun. For--max-run-duration specifically, theterminationTimestamp
is thesum of MAX_RUN_DURATION and the time when the VM last entered theRUNNING
state, which changes whenever the VM is rerun.
- Sole Tenancy.
At most one of these can be specified:
--clear-node-affinities
- Removes the node affinities field from the instance. If specified, the instancenode settings will be cleared. The instance will not be scheduled onto asole-tenant node.
--node
=NODE
- The name of the node to schedule this instance on.
--node-affinity-file
=PATH_TO_FILE
- The JSON/YAML file containing the configuration of desired nodes onto which thisinstance could be scheduled. These rules filter the nodes according to theirnode affinity labels. A node's affinity labels come from the node template ofthe group the node is in.
The file should contain a list of a JSON/YAML objects. For an example, seehttps://cloud.google.com/compute/docs/nodes/provisioning-sole-tenant-vms#configure_node_affinity_labels.The following list describes the fields:
key
- Corresponds to the node affinity label keys of the Node resource.
operator
- Specifies the node selection type. Must be one of:
IN
: RequiresCompute Engine to seek for matched nodes.NOT_IN
: Requires ComputeEngine to avoid certain nodes. values
- Optional. A list of values which correspond to the node affinity label values ofthe Node resource.
Use a full or relative path to a local file containing the value ofnode_affinity_file.
--node-group
=NODE_GROUP
- The name of the node group to schedule this instance on.
- Termination Time
At most one of these can be specified:
--clear-termination-time
- Removes the termination-time field from the scheduling options.
--termination-time
=TERMINATION_TIME
- Limits how long this VM instance can run, specified as a time. Format the time,TERMINATION_TIME, as a RFC 3339 timestamp. For more information, seehttps://tools.ietf.org/html/rfc3339.Alternatively, to specify a duration, use --max-run-duration instead.
If neither --termination-time nor --max-run-duration is specified (default), theVM instance runs until prompted by a user action or system event. If either isspecified, the VM instance is scheduled to be automatically terminated at theVM's termination timestamp (
terminationTimestamp
) using the actionspecified by --instance-termination-action.Note: The
terminationTimestamp
is removed whenever the VM isstopped or suspended and redefined whenever the VM is rerun. For--termination-time specifically, theterminationTimestamp
remainsthe same whenever the VM is rerun, but any requests to rerun the VM fail if thespecified timestamp is in the past.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file
,--account
,--billing-project
,--configuration
,--flags-file
,--flatten
,--format
,--help
,--impersonate-service-account
,--log-http
,--project
,--quiet
,--trace-token
,--user-output-enabled
,--verbosity
.Run
$gcloud help
for details. - NOTES
- These variants are also available:
gcloudalphacomputeinstancesset-scheduling
gcloudbetacomputeinstancesset-scheduling
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-05-07 UTC.