In our GCP project we have a few VMs in Compute engine for some testing purposes. Collogues often forget them running after work. Is it possible to schedule a cron job with Cloud Scheduler, that turns off the machines at a certain hour every day or should I use some other GCP service for that?
I went to the VM settings but couldn't find such options. Is it possible that startup/shutdown options are available only at creation time?
As mentioned in this blog written by Vishal Bulbule, you can schedule your VM restarts by following the below steps:
Go to compute Engine page.
Click the Instance schedules tab at the top of the page
Click Create schedule. The Create a schedule pane opens.
Enter a Name. Optional: Enter a Description.
In the Region drop-down menu, select the location for this instance schedule.
Define when the instance schedule starts and stops any attached VM instances.
If you need VM instances to start or stop at a specific time, schedule the operation 15 minutes earlier than needed. Make sure each start and stop operation are at least 15 minutes apart.
Enter a Start time, a Stop time, or both in 24 hr format or use cron expression.
Optional: In the Initiate date field, type or click date_range to select the date and time when you want this instance schedule to begin. If omitted, the schedule is effective immediately.
Optional: In the End date field, type or click date_range to select the date and time when you want this instance schedule to end. If omitted, the schedule is effective indefinitely.
Click Submit. Click on the name of the instance schedule that you want to attach. The Instance schedule details page opens.
Click Add instances to schedule.
The Add instances to schedule pane opens. Select the checkbox for each VM instance that you want to attach this schedule to Instance.
Click Add.
If you want to have additional features you can use some third party tools as mentioned in the blog.
Note: The steps given above are taken from the blog which has been embedded in the content above