在远程服务器上安装了anaconda,通过Xshell(或者finalShell)终端运行juypter notebook,一段时间不动连接断开,本地运行的浏览器端jupyter notebook 也就停了。
原因是当前jupyter建立在了终端链接上了。
怎样才能在Linux后台运行jupyter notebook?也就是在服务器一直挂着,即使Linux前端断了也能继续运行jupyter.
其实非常简单,代码如下:
nohup jupyter notebook --no-browser --ip=127.0.0.1 --allow-root &
这里nohup:no hang up表示进程不挂起,即使shell终端停止后,jupyter也不停止。
&:表示将命令放在后台执行。
怎样查看后台的jupyter进程呢?
ps -ef |grep XXXX
ps -ef:可以列出当前服务器运行的所有进程。grep xxxx:可以根据条件过滤。
从上图可以看到jupyter进程的PID。若想结束,可以用kill 杀死进程。
kill -9 PID