Skip to content

Instantly share code, notes, and snippets.

@33eyes
Last active April 9, 2024 08:56
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save 33eyes/e1da2d78979dc059433849c466ff5996 to your computer and use it in GitHub Desktop.
Save 33eyes/e1da2d78979dc059433849c466ff5996 to your computer and use it in GitHub Desktop.
Jupyter notebook with nohup

Running jupyter notebook with nohup

This is helpful when running jupyter notebook on remote server (AWS) and tunneling into it, because with nohup the notebook process continues to run on the server even if you get disconnected from it (any running notebook code continues to run on the server without interruption, and just needs to be re-tunneled into).

Start jupyter notebook on remote server

In the remote server terminal, run:

nohup jupyter notebook &

(the & sends the process to run in the background, so that the terminal window can be used)

Tunnel into the remote jupyter notebook from local

In the local terminal, run:

ssh awsgpu -NL 8157:localhost:8888 ubuntu@11.111.111.11

replacing awsgpu with remote server ssh login, 8157 with a free local port, 8888 with the port used by jupyter notebook on the remote server (usually it's 8888), and 11.111.111.11 with remote server IP.

Stop the remote jupyter notebook

Since we now have a jupyter notebook running in the background, we can't stop the notebook by closing the terminal window or Ctrl C. Here are the steps to stop it.

  • check what jupyter notebooks are running:
jupyter notebook list

(note which ports are being used)

  • find which process IDs (PIDs) are being run on the port used by the jupyter notebook(s):
netstat -tulpn

Look for processes that are running on port 8888 (or whichever port was listed in the step above), and note the PID.

  • now kill the process(es):
kill 2759

replace 2759 with the PID from the step above.

@luohui2000
Copy link

what if I wanna run "jupyter notebook --ip=0.0.0.0 --NotebookApp.token='' --NotebookApp.password=''"

@redpoint13
Copy link

redpoint13 commented May 3, 2023

nohup jupyter notebook --ip=0.0.0.0 --NotebookApp.token=''" --NotebookApp.password=''" &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment