简体   繁体   中英

How to run a VM in gcp in the background?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM