Is it possible to run startup scripts only for first boot on GCP?

Viewed 763

Suppose, I have requirement to run startup scripts only on first boot of the vm. My vm can start/stop frequently and I don't want to run script in every boot. As per GCP doc startup scripts runs every time your instance boots up.

1 Answers

Startup scripts run on each boot. There is no "run once" setting/option.

I recommend setting a flag, such as a file on disk after a script runs. Then check for the existence of this flag at the start of your script and exit if it exists.

Related