Persistent use of Jupyter Notebook from remote server

Michael D picture Michael D · Aug 23, 2017 · Viewed 11.4k times · Source

I connect to a remote server using ssh -L but if I close the laptop lid or the connection is lost, the jupyter notebook is disconnected.

After I reconnect to the remote server, the "last" session is lost.

What can be done to make it persistent? Could screen help with it?

Answer

BiBi picture BiBi · Aug 23, 2017

On the remote server, you should open your jupyter in a screen session, it will make it persistent if you lose the connection to the server and resume it.

  1. On your computer: ssh -L xxxx:localhost:yyyy server.
  2. screen.
  3. jupyter notebook --no-browser --port=yyyy.
  4. In your browser: localhost:xxxx.

To disconnect manually and reconnect:

  1. Exit the screen window: control + a and then d.
  2. Disconnect from the server: control + d
  3. And reconnect ssh -L xxxx:localhost:yyyy.
  4. Optionally, you can reopen the screen window, though unnecessary, using screen -r.
  5. Go back to your notebook or reopen localhost:xxxx.