I am using Jupyter Notebook for a project. Since I ssh into a linux cluster at work I use
ssh -Y -L 8000:localhost:8888 user@host
Then I start the notebook with jupyter notebook --no-browser &
so that I can continue using the terminal. Then on my local machine I open to localhost:8000
and go about my work.
My problem is that I forgot several times to close the server by foregrounding the process and killing it with Ctrl-C
. Instead I just logged out of the ssh session. Now when I run jupyter notebook list
I get
Currently running servers: http://localhost:8934/ :: /export/home/jbalsells http://localhost:8870/ :: /export/home/jbalsells http://localhost:8892/ :: /export/home/jbalsells http://localhost:8891/ :: /export/home/jbalsells http://localhost:8890/ :: /export/home/jbalsells http://localhost:8889/ :: /export/home/jbalsells http://localhost:8888/ :: /export/home/jbalsells
I obviously do not want all of these servers running on my work's machine, but I do not know how to close them!
When I run ps I get nothing:
PID TTY TIME CMD 12678 pts/13 00:00:00 bash 22584 pts/13 00:00:00 ps
I have Jupyter 4.1.0 installed.
Normally, you can kill a Jupyter server from the same terminal window where you launched your Jupyter notebook by hit CTRL + C, then type yes, to shut down the kernels of Your jupyter notebook.
Closing JupyterLabClick “Shut Down” to shutdown the JupyterLab server. To restart the JupyterLab server you will need to re-run the following command from a shell.
3.Run the jupyter notebook in the browser of the server Then, navigate to the respective jupyter notebook file in the browser and open it. Click Cell > Run All on the toolbar. All done! Now you can leave the browser running in the remote desktop and disconnect to it anytime you want to.
So I found a solution.
Since jupyter notebook list
tells you which ports the notebook servers are running on I looked for the PIDs using netstat -tulpn
I got the information from http://www.cyberciti.biz/faq/what-process-has-open-linux-port/
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8649 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:33483 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 39125/Xvnc
Without looking too hard I was able to find the ports I knew to look for from jupyter notebook list
and the processes running them (you could use grep
if it were too hard to find them). Then I killed them with kill 8337
(or whatever number was associated).
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