列出正在运行的 Jupyter 笔记本和令牌 [英] List running Jupyter notebooks and tokens
问题描述
如何检查所有正在运行的 jupyter notebook 实例的登录令牌?
How do you check the login tokens for all running jupyter notebook instances?
示例:你有一个笔记本永久运行在 tmux
或 screen
中,并通过 ssh
远程登录.有时,特别是当您在很长时间后登录时,会再次请求令牌以访问笔记本会话.如何在不必使用新令牌终止和重新启动笔记本会话的情况下获取令牌?
Example: you have a notebook running in tmux
or screen
permanently, and login in remotely through ssh
. Sometimes, particularly if you're logging in after a long time, the token is requested again in order to access the notebook session. How do you get hold of the token without having to kill and restart the notebook session with a new token?
推荐答案
UPDATE
您现在只需在终端中运行 jupyter notebook list
即可使用令牌获取正在运行的 jupyter 会话.
You can now just run jupyter notebook list
in the terminal to get the running jupyter sessions with tokens.
请注意您处于正确的环境(conda、virtualenv 等)中,否则会话将在没有关联令牌的情况下列出.例如:以上参考截图来自 conda 环境.
Take care that you are within the right environment (conda, virtualenv etc.) otherwise the sessions will list without the associated tokens. Eg: The above reference screenshot is from the conda environment.
旧答案:
运行 ipython 并输入以下内容:
Run ipython and enter the following:
> ipython
[1] : system("jupyter" "notebook" "list")
Out[1]:
['Currently running servers:','http://localhost:8895/token=067470c5ddsadc54153ghfjd817d15b5d5f5341e56b0dsad78a :: /u/user/dir']
如果笔记本在远程服务器上运行,您必须先登录到该服务器,然后才能运行 ipython.
If the notebook is running on a remote server, you will have to login in to that server first before running ipython.
这篇关于列出正在运行的 Jupyter 笔记本和令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!