参考 https://blog.csdn.net/karmayh/article/details/108798550
- 先尝试
jupyter notebook stop
2.1失败时,使用
jupyter notebook list #查看当前jupyter端口
lsof -n -i4TCP:[port-number] # 通过端口获得pid
kill -9 [PID] # 删除进程
3.关闭所有jupyter server
import re
port_lines = !jupyter notebook list
ports = []
for line in port_lines:
ports+=re.findall(r'(?:http://0.0.0.0:)(\d+)(?:/)',line)
print ports
pids = []
for port in ports:
out = !lsof -n -i4TCP:$port
pid = out[1].split()[1]
pids.append(pid)
print pids
for pid in pids:
!kill -9 $pid