Cameron Wasilewsky
Cameron Wasilewsky

Reputation: 1052

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.

Upvotes: 4

Views: 2874

Answers (2)

Raghavan
Raghavan

Reputation: 96

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.

Upvotes: 7

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

It sounds like you're referring to the Google Cloud Shell feature. If so then what you desire is not possible, the cloud shell is not intended for non-interactive operation. From Usage limits:

Cloud Shell is intended for interactive use only. Non-interactive sessions will be ended automatically after a warning.

The cloud shell operates on a temporary Compute Engine virtual machine, which is running only while the cloud shell session is active in the browser.

Apart from the obvious approach of keeping the browser session active while your application is running, you could also provision yourself a non-temporary Compute Engine instance (a free one is available), to which you can connect and on which you can run non-interactive applications as you desire.

Upvotes: 1

Related Questions