Currently I schedule my instance shutdown in Google Cloud Platform (GCP) the following way via /etc/crontab
:
30 23 * * * sudo poweroff
This is done inside GCP instance.
Is there better way to do it using GCP-API? And how can I schedule the instance starting? I can't seem to do that even with crontab.
Best Answer
There is a great tutorial in the Google Cloud Site. The address is
https://cloud.google.com/scheduler/docs/start-and-stop-compute-engine-instances-on-a-schedule
Extra note to help with the tutorial:
When you get to the part where you are setting up the Functions. You may need to do base64 conversion if you are using the free tier option, the tutorial is for the west zone and free tier is only available in the central zone. Also once you have the string converted you need to remove the OK from the end and add
o=
There are my notes of the process:
sample string:
sample as base 64
converter url:
https://www.base64encode.net/
results using sample string above
The results are the same as the sample except the different in the last to characters.
desired input string:
output base 64 string
Add the JSON formatting and adjust the last to characters:
Hope it helps you get the base64 string conversion bit.