centos7下如何将服务挂在服务器后台?---亲测可行
首先,linux可以使用多种远程连接,比如xshell,然后类似xshell这种远程连接方式也需要注意几点。
启动某个pythonweb项目或者其它项目是,断开连接的时候有可能会断开服务。
linux下如何把某个即将运行项目服务挂在后台运行而断开xshell的时候服务不停止呢:
nohup 你的命令 &
比如 nohup python3 flask_demo.py &
&的意思是把服务挂在后台运行,nohup意思就是在断开ssh连接通道的时候这种服务还保持着。
如何关闭nohup的进程:
ps -ef|grep start # (查找运行该命令的进程) kill -9 pid #(根据进程号关闭程序)
或者根据端口号查看进程然后将其kill掉:
netstat -anp | grep xxxx #xxxx为端口号
或者
lsof -i :xxxx #xxxx为端口号
或者
netstat -nap | grep port
比如将jupyter 服务挂起在后台,方便随时访问:
【记得设置好jupyter登录密码和搞好基础jupyter配置喔】
nohup jupyter notebook & nohup jupyter lab &
那该如何关闭nohup开启的jupyter后台进程呢?
ps -aux|grep jupyter| grep -v grep
或者
ps -aux|grep jupyter| grep -v grep | awk '{print $2}'
使用上面的命令查看开了那些进程是关于jupyter的,然后将其kill掉.

浙公网安备 33010602011771号