Home > Software engineering >  How to run a VM in gcp in the background?
How to run a VM in gcp in the background?

Time:05-18

I have a gcp linux VM, very basic question: If I have a simple script like this:

import time
for a in range (0,1000):
    print(a)
    time.sleep(10)

when I enter the console via ssh in browser connection I run the script, but it stops when I close the window. How do I make it run even when I shut down my PC?

CodePudding user response:

You can use nohup.

For example:

nohup python myscript.py &

And then you may close the session. The script will keep running on the remote VM, til it finishes.

  • Related