列出运行木星笔记本和代币

如何检查所有正在运行的 Jupyter 笔记本实例的登录令牌?

例如: 您有一个永久运行在 tmuxscreen中的笔记本,并通过 ssh远程登录。有时,特别是当您在很长一段时间后才登录时,会再次请求令牌以访问笔记本会话。如何获得令牌而不必杀死和重新启动笔记本会话与一个新的令牌?

146140 次浏览

UPDATE

You can now just run jupyter notebook list in the terminal to get the running jupyter sessions with tokens.

enter image description here

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.

Old answer:

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']

If the notebook is running on a remote server, you will have to login in to that server first before running ipython.

For running python code in jupyter notebook...we need token id which we can obtain from the terminal by just typing jupyter notebook provided your path has been configured... If not then set your path right first.

Sample

One easy solution (that can save you time by avoiding opening a new terminal) is from the same terminal you are running the notebook to hit (ONLY ONCE!! - cause twice would kill the running server)

Ctrl + C

By doing that the full link to your notebook will appear (along with the token!) and a prompt asking you to confirm shutting down. Just answer no (n and enter) or do nothing and after 5 seconds the operation will resume. In the meanwhile you would have been able to retrieve the link and/or the token you need.

Just right click on the jupyter notebook logo in the currently running server, you probably have a server running already, then click on copy link, then paste the link in a text editor, maybe MS word, you will see the token in the link, copy and paste where token is required. It will work.

Use this command

$ jupyter server list

It will display the currently running servers for both jupyter lab and jupyter notebook along with the tokens.