在linux中设置后台运行Python脚本命令

在linux中设置后台运行Python脚本命令:

nohup python xxxx.py &

如果报错为: nohup: ignoring input and appending out
解决办法为:

chmod +x hello.py
nohup python hello.py >/dev/null 2>&1 &

这样将.py文件更换成我们自己的就可以了。这里仅仅是后台运行,但是我们如果希望确保重启和服务器变动之后也保持运行,则需要添加到开机启动项中(Debian/Ubuntu系统设置开机启动项的方法)。

猜你喜欢

转载自blog.csdn.net/longe20111104/article/details/89486994