
Startup scripts and stop scripts
Startup scripts allow you to run a script when starting up or creating an instance. For instance, to always install miniconda and related data science packages when creating a new instance, simply write the following script in a file on your local machine:
Then as you start the new instance, supply the --metadata-from-file flag, followed by startup-script=PATH/TO/FILE, where PATH/TO/FILE is a relative path to the startup script:
You can also use a startup script in extension in the command line or from a file stored in Google Storage. For more on startup scripts, visit https://cloud.google.com/compute/docs/startupscript.
Stop scripts are scripts that are automatically run when an instance is terminated or restarted. Similar to startup scripts, you can associate a stop script with an instance at creation by adding the --metadata-from-file flag, followed by shutdown-script=PATH/TO/FILE: