gpt4 book ai didi

python - 无法退出正在运行的 jupyter notebook 服务器

转载 作者:IT老高 更新时间:2023-10-28 20:51:27 28 4
gpt4 key购买 nike

我正在为一个项目使用 Jupyter Notebook。因为我在工作中使用 ssh 进入 linux 集群,所以我使用

ssh -Y -L 8000:localhost:8888 user@host

然后我用 jupyter notebook --no-browser & 启动笔记本,这样我就可以继续使用终端了。然后在我的本地机器上打开 localhost:8000 并开始我的工作。

我的问题是我多次忘记通过将进程置于前台并使用 Ctrl-C 杀死它来关闭服务器。相反,我刚刚退出了 ssh session 。现在当我运行 jupyter notebook list 我得到

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

我显然不希望所有这些服务器都在我工作的机器上运行,但我不知道如何关闭它们!

当我运行 ps 时,我什么也得不到:

  PID TTY          TIME CMD
12678 pts/13 00:00:00 bash
22584 pts/13 00:00:00 ps

我安装了 Jupyter 4.1.0。

最佳答案

所以我找到了解决办法。

由于 jupyter notebook list 告诉您笔记本服务器在哪些端口上运行,我使用 netstat -tulpn 查找 PID,我从 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

不用太费力,我就能从 jupyter notebook list 中找到我知道要查找的端口以及运行它们的进程(如果是,您可以使用 grep很难找到它们)。然后我杀了他们kill 8337(或任何相关的号码)。

关于python - 无法退出正在运行的 jupyter notebook 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38511673/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com