> ## Documentation Index
> Fetch the complete documentation index at: https://help.nops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Schedule Non-Production Compute Engine Instances

> Stop non-production Compute Engine VMs that run around the clock outside working hours with an instance schedule.

Development, test and staging VMs are often left running all night and every weekend. nOps finds non-production Compute Engine instances that run nearly 24 hours a day, including weekends, and estimates the saving from running them only 12 hours a day on weekdays (60 of the 168 hours in a week).

| | |
| - | - |
| **Cloud** | Google Cloud |
| **Category** | Compute |
| **Service** | Compute Engine |
| **Action** | Modify |
| **Effort** | Low |
| **Restart needed** | Yes |
| **Can be rolled back** | Yes |
| **Analysis window** | Last 14 days |
| **Source** | nOps |

## Why it matters

A VM that only needs to run during the working week can cut its compute cost by almost two thirds with a schedule, with no change to its size or configuration.

## How nOps finds it

nOps reads Compute Engine billing for each instance over the last 14 complete days. An instance is flagged when it was billed on all 14 days, ran at least 20 hours a day on average, and ran at least 20 hours on at least 3 of the 4 weekend days. It must be non-production: nOps looks at the instance's own environment label, then the environment nOps assigns, then the project name, and at least 90% of its cost must be non-production. GKE nodes (unless their own label marks them non-production) and instances where committed-use discounts cover more than half the cost are left out, and Spot usage is not counted. The saving is the instance's pay-as-you-go vCPU, memory and GPU cost over the last 7 days (net of committed-use and sustained-use credits), scaled to a month, times 108/168. It must be at least \$25 a month. Projects whose spend on the service is at least 90% paid by credits or promotions are left out.

## Before you start

Agree working hours with the team that uses the VM. Instance schedules need the Compute Engine service agent to have permission to start and stop instances.

## How to implement

1. Confirm nobody needs the VM overnight or at weekends, including scheduled jobs and backups.
2. Create an instance schedule: `gcloud compute resource-policies create instance-schedule SCHEDULE_NAME --region=REGION --vm-start-schedule='0 8 * * MON-FRI' --vm-stop-schedule='0 20 * * MON-FRI' --timezone=TIME_ZONE`.
3. Attach it to the VM: `gcloud compute instances add-resource-policies VM_NAME --resource-policies=SCHEDULE_NAME --zone=ZONE`. In the console, this is **Compute Engine → Instance schedules**.
4. If the VM belongs to a managed instance group, schedule the group's size instead (resize to 0 out of hours), because the group recreates stopped members.
5. If it is a GKE node, scale its node pool to zero on a schedule instead of stopping the VM.

## Risks and considerations

* Persistent disks and reserved IP addresses keep billing while the VM is stopped.
* Sustained-use discounts shrink when a VM runs fewer hours, so the real saving can be a little lower.
* This and running the VM as a Spot VM are alternatives for the same instance. Apply one or the other, not both.
* To roll back, detach the schedule from the VM.

## FAQs

> [accordion] How does nOps decide a VM is non-production?
>
> From the VM's own environment label first, then the environment nOps assigns to it, then words in the project name such as dev, test, staging or sandbox.

> [accordion] Can I use different hours?
>
> Yes. The estimate assumes 12 hours on weekdays. A longer schedule saves less, a shorter one more.

## Related

* [Use Spot VMs for Non-Production Compute Engine Instances](https://help.nops.io/inform/supported-recommendations/use-spot-vms-for-non-production-compute-engine-instances)
* [Use Spot Node Pools for Non-Production GKE Clusters](https://help.nops.io/inform/supported-recommendations/use-spot-node-pools-for-non-production-gke-clusters)
* [Schedule Non-Production Azure VMs](https://help.nops.io/inform/supported-recommendations/schedule-non-production-azure-vms)
* [Supported recommendations](https://help.nops.io/inform/supported-recommendations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.