Tanner L.
Tanner L.

Reputation: 41

Google Compute Engine instance restarts when I ssh

I have a deep learning vm setup on google cloud platform. I ssh into by clicking the ssh button in my list of vm instances. The problem I am having is that if I run a program and close the ssh window while it is still running, when I ssh back into the vm, the program has been interrupted and the whole vm essentially has restarted.

Is there a way to setup my vm so that I can run a program and then close the ssh connection without it restarting the vm? I want to be able to run programs without being required to leave the ssh window open and my computer on.

Upvotes: 0

Views: 82

Answers (1)

Tanner L.
Tanner L.

Reputation: 41

As @Rup pointed out, processes belonging to your SSH session's shell will get a hang-up signal when you close the connection. To bypass the hang-up signal and let a program continue running, use the nohup command. Here is an example

nohup python test.py &

That will run the program test.py and as well as ignore the hang-up signal. The programs output will be stored in a nohup.out file.

Upvotes: 3

Related Questions