如何释放笔记本服务器停止后占用的端口?
How do I release ports which are being held by a notebook server after it has been stopped?
我正在 AWS 实例(Redhat Linux 服务器)上启动一个 jupyter notebook 服务器以通过 https 连接。在配置文件中,我知道这应该在端口 9999 上。但是,当我使用 Ctrl-C 停止并重新启动进程时,端口没有被释放,如下所示。
[user@ip-xxx-xx-xx-xxx notebook]$ [I 08:39:27.901 NotebookApp] The port 9999 is already in use, trying another random port.
[I 08:39:27.901 NotebookApp] The port 10000 is already in use, trying another random port.
[I 08:39:27.902 NotebookApp] The port 10001 is already in use, trying another random port.
[I 08:39:27.905 NotebookApp] Serving notebooks from local directory: /home/user/docs/notebook
[I 08:39:27.905 NotebookApp] 0 active kernels
[I 08:39:27.905 NotebookApp] The Jupyter Notebook is running at: https://[all ip addresses on your system]:10002/
[I 08:39:27.905 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
顺便说一句,那些 "random ports" 在我看来不是很随意。
有时服务的停止命令不会return任何错误并删除进程的 pid 文件,但实际上不会终止进程本身。
您可以通过 运行 停止命令检查进程是否仍然 运行 然后
ps aux | grep -i notebook
或
netstat -tlnp | grep <portNumber>
如您所述,您可以手动终止进程,或修复停止脚本(通常为 /etc/init.d/serviceName+d)。进程未被杀死的原因通常(不总是)与执行命令的用户拥有的权限有关
我正在 AWS 实例(Redhat Linux 服务器)上启动一个 jupyter notebook 服务器以通过 https 连接。在配置文件中,我知道这应该在端口 9999 上。但是,当我使用 Ctrl-C 停止并重新启动进程时,端口没有被释放,如下所示。
[user@ip-xxx-xx-xx-xxx notebook]$ [I 08:39:27.901 NotebookApp] The port 9999 is already in use, trying another random port.
[I 08:39:27.901 NotebookApp] The port 10000 is already in use, trying another random port.
[I 08:39:27.902 NotebookApp] The port 10001 is already in use, trying another random port.
[I 08:39:27.905 NotebookApp] Serving notebooks from local directory: /home/user/docs/notebook
[I 08:39:27.905 NotebookApp] 0 active kernels
[I 08:39:27.905 NotebookApp] The Jupyter Notebook is running at: https://[all ip addresses on your system]:10002/
[I 08:39:27.905 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
顺便说一句,那些 "random ports" 在我看来不是很随意。
有时服务的停止命令不会return任何错误并删除进程的 pid 文件,但实际上不会终止进程本身。
您可以通过 运行 停止命令检查进程是否仍然 运行 然后
ps aux | grep -i notebook
或
netstat -tlnp | grep <portNumber>
如您所述,您可以手动终止进程,或修复停止脚本(通常为 /etc/init.d/serviceName+d)。进程未被杀死的原因通常(不总是)与执行命令的用户拥有的权限有关