2016-11-10 170 views
0

现在这个问题可能看起来像一个问题,如this one和this之一。执行Python脚本不挂终端

不幸的是,上述解决方案不适合我。我需要一种方法来执行一个Python 3.4.3脚本,在终端关闭时让它运行,并让它不会挂在终端上并直接执行。

[email protected]:/var/www/html/mysite/scripts $ nohup python3 my.script.py &                                       

上面运行脚本,但它在终端挂机按CTRL + C,直到我停止它不能输入任何其他命令。

有没有办法实现这样的事情:

[email protected]:/var/www/html/mysite/scripts $ nohup python3 my.script.py & 
[email protected]:/var/www/html/mysite/scripts $ 
(Now I enter more commands, despite the script still running) 

我希望我能提供足够的信息,希望你能帮助我,谢谢!

+0

看起来你只是错过了&符。 'nohup python3 my.script.py&' – smarx

+1

使用符号,脚本应该在后台运行。我不知道还有什么要告诉你。也许复制/粘贴你执行的确切命令?并告诉我们你是如何确定它“悬挂”终端的? – smarx

+0

'www-data @ raspberrypi:〜/ html/mysite/scripts $ nohup python3 my.script.py&' – Will

回答

0

基于一个快速谷歌搜索,我发现

start /b python3 my.script.py 

for Windows或

python3 my.script.py & 

上LUNIX(庆典)。

+0

'bash:start:command not found' – Will

+0

@Will>“for windows” - 对于bash,请使用第二个命令。 – Dartmouth

+0

我最终用'python3 myscript.py 1>/dev/null'修复了它# – Will

0

如果&字符不起作用,您可以使用终端多路复用器,如GNU screentmux您的目的。

+0

我最终用'python3 myscript.py 1>/dev/null'修复了它 – Will