Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reconnect to Google Cloud Platform Terminal

I am running a python machine learning script on google cloud platform. I have connected through SSH in browser. When I run the code it works, but when I close the browser it seems to stop running.

I believe I can make it run in the background with nohup, but I want to be able to check back in on it as it prints outputs on its progress.

Basically I want to be able to start the script, close the terminal and then reconnect from any machine to check on its progress. Any help would be really appreciated.

I am new to google cloud platform if any of this was unclear please as an ill try providing more detail.

like image 563
Cameron Wasilewsky Avatar asked Oct 17 '25 15:10

Cameron Wasilewsky


1 Answers

You may use an app called as screen. Just install it using `sudo apt-get install screen`` (if debian, ubuntu). In some cases it might be already installed in your instance, you may check it.

Once installed enter the following command into the terminal:

screen 

and press enter. Now, You may start with your job in terminal.

The moment you need to disconnect you may press Ctrl+A and then d. The session would be disconnected. You may note the session id that would be displayed (eg. detached from 1498.pts-1.server)

You may now close the terminal.

When you come back, use the following command to get back into the older session.

screen -r *screen_id* (eg. screen -r **1498.pts-1.server**)

This process is checked for google cloud, ssh through browser, it really works.

Check this site for mode details.

like image 131
Raghavan Avatar answered Oct 20 '25 18:10

Raghavan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!