I use Google Cloud Shell to run Jupyter Notebook on instance , but after 1 hours
,the connection is disconnect.
And I reconnect to instance, there is nothing, is same as reset instance.
So, please tell me how to set up ,make the connection of cloud shell keep connect.
Thanks!
Disable Cloud Shell for managed user accounts This can be done by going to the Google Admin console and then navigating to Apps > Additional Google services > Google Cloud Platform > Cloud Shell Settings and disabling "Cloud Shell Access Settings".
Cloud Shell is intended for interactive use only. Non-interactive sessions are ended automatically after one hour. Cloud Shell sessions are capped at 12 hours, after which sessions automatically terminate. You can start a new session immediately after.
Google cloud has a session timeout across the board of 10 minutes, so you need to use a keepalive . Try adding the argument --ssh-flag="-ServerAliveInterval=30" - any value less than 600 should do the trick there. There's a description of the timeout here, and full usage details for gcloud ssh here. Save this answer.
With Cloud Shell, the Cloud SDK gcloud command and other utilities you need are always available when you need them. In this codelab, you will learn how to connect to computing resources hosted on Google Cloud Platform via the web.
Google Cloud Shell auto disconnect because you didn't do anything in the Cloudshell's terminal! So to keep the cloudshell session alive, you can enter the following javascript code to the browser's javascript console
setInterval(function() {document.elementFromPoint(500, 500).click();}, 30000);
That's the trick!
P/S: If you want to use Jupyter Notebook, why you don't use Google Colab instead? It has a pre-installed Jupyter Notebook as well as more CPU and ram. You can use the same js for Colab!
UPDATE: you can try Cloud Shell SDK, then connect to Google Cloud Shell by gcloud cloud-shell ssh
, which is much faster than the web interface, allow port forwarding (based on ssh), and have a longer time limit.
You can even connect to it using VSCode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With