[英]Jupyter: How to list running kernels and which notebook started them?
I haven't found answers in github or in the jupyter help.我没有在 github 或 jupyter 帮助中找到答案。
TL;DR : I need a command-line that tells me the same thing as the %connect_info
magic, in particular the line Connect with --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json
. TL;DR :我需要一个命令行来告诉我与%connect_info
魔术相同的内容,尤其是Connect with --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json
。
My current setup is to have the jupyter notebook launched from a work server.我当前的设置是让 jupyter notebook 从工作服务器启动。 Then I connect to that server with SSH, and can work in the same kernel by attaching a console to it:然后我使用 SSH 连接到该服务器,并且可以通过将控制台附加到它来在同一个 kernel 中工作:
jupyter console --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json
(in a tmux
+ vim
+ slimux
setup, which by the way I often find more convenient). (在tmux
+ vim
+ slimux
设置中,顺便说一下,我经常觉得这更方便)。
The problem is:问题是:
So is there a command to run from the shell on the server, that would list running kernels , which notebook launched them , and ideally if there are consoles attached ?那么是否有从服务器上的 shell 运行的命令,它会列出正在运行的内核、哪个笔记本启动了它们,理想情况下是否连接了控制台?
You can list the kernel json files sorted by time with:您可以列出按时间排序的 kernel json 文件:
ls -tlr ~/.local/share/jupyter/runtime/
-rw------- 1 user user 263 6. Dez 13:40 kernel-c64635b5-6f5c-4938-828b-520d70e2a6c4.json
-rw------T 1 user user 263 7. Dez 11:57 kernel-1bdb41b4-1e87-4672-af92-7c3f3660e19c.json
-rw------T 1 user user 263 7. Dez 16:48 kernel-f7a51511-8c2a-4f0b-9cd3-6e5a79dccab3.json
This will not give you the information about which notebook launched them and if there is a console attached.这不会为您提供有关哪个笔记本启动它们以及是否连接了控制台的信息。 But the times will give you some hints of which kernel is the one you are looking for, and with some trial and error you will figure it out.但是时代会给你一些提示,告诉你 kernel 是你要找的那个,通过一些试验和错误你会弄明白的。
This answer is based on the blog post “Connecting with Ipython from the command line to a running Jupyter session” by DS4N6.此答案基于 DS4N6 的博客文章“Connecting with Ipython from the command line to a running Jupyter session”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.