El pocho la pantera
El pocho la pantera

Reputation: 505

Create an instance, execute a long script and then kill it

I'm starting to use Google Cloud Engine, what I need to do is to use the python-api to:

  1. Create a new instance (i'm already doing this)
  2. Execute a python script, a very long one taking about 12 hours
  3. Once the execution is finished, delete the instance

Now im using a startup-script, but I'm having some problems as it's not loading conda correctly, and I need to run 'conda activate'. I'm actually thinking a startup script might not be the best way...

Also, is there any way to monitor the progress of the script on the instance? I found this getSerialPort method, but seems I need to do a sort of busy-waiting calling it all the time and printing the output till it finishes.

Thanks, Marcelo

Upvotes: 0

Views: 169

Answers (1)

Cloudkollektiv
Cloudkollektiv

Reputation: 14709

You need to enable interactive serial console access for a specific instance (there is also a project wide setting):

gcloud compute instances add-metadata instance-name \
    --metadata serial-port-enable=TRUE

Then listen to the logging on the serial port:

gcloud compute connect-to-serial-port instance-name

Upvotes: 1

Related Questions