后台运行python
方法1:使用nohup
$ nohup python ***.py &
输入这条指令后使用exit
退出ssh客户端.
方法2:用screen来后台运行工程
###首先安装screen
###创建screen
在命令行输入
screen
来开启新的窗口,在里面运行python xxxx.py
现在就算ssh挂了该进程也不会死,而且可以通过后面的手段重新打开该进程
###重新回到窗口
screen -ls
可以看到目前后台运行的screen的id
如果dettached、
screen -r id
如果attached
screen -rd id
这里好处是,screen也可以显示程序的输出
但是还是推荐把输出写入txt里面