1.使用nohup让python脚本在后台运行,退出ssh的时候不会导致脚本停止
nohup python3 MqInfoServer.py > log.out &
其中&代表后台运行,此后终端能继续输入
> log.out 表示把终端输出的打印到文件log.out中
2.停止nohup启动的后台
root@xxx:/home/python/PyClient# ps -ef | grep python
root 508 1 0 11:27 ? 00:00:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 5011 4912 0 19:58 pts/0 00:00:00 python3 MqInfoServer.py
root 5040 4912 0 20:03 pts/0 00:00:00 grep --color=auto python
查看后台python相关进程
停止5011的进程
kill 5011