后台运行py文件:解决"ignoring input and appending output to ‘nohup.out’"问题

在编译执行python文件的时候,采用nohup进行后台自动运行,但是在执行文件的时候出现"nohup: ignoring input and appending output to ‘nohup.out’"的错误提示。搜索文章之后将 解决办法记录下来。直接抛弃概念性的文件,直接将如何解决记录。

chmod +x hello.py

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

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

你可能感兴趣的:(Python,Linux)