我尝试了nohup "sbt run" &
返回:nohup: failed to run command ‘sbt run’: No such file or directory
并尝试:
nohup sbt run & [2] 7897 # nohup: ignoring input and appending output to ‘nohup.out’当我回车期望过程继续运行时,我收到:
When I carriage return expecting process to continue running I receive :
[2]+ Stopped nohup sbt run如何将sbt作为守护程序运行?
How to run sbt as a daemon ?
更新:
sbt run </dev/null & [5] 8961我认为cd指向一个目录:
I think cd up one dir :
# cd .. [5]+ Stopped sbt run < /dev/null (wd: /home/sum) (wd now: /home)所以它作为守护程序启动,但是如果我执行任何操作(例如更改dir),它将终止该进程?如何保持进程运行?
So it starts as daemon but if I perform any actions such as changing dir it kills the process ? How to keep process running ?
推荐答案看起来像sbt从您的终端请求的输入.如果确实不需要输入(可能是在后台运行程序),则可以这样运行:
Looks like sbt requested input from your terminal. If it does not really need input (which is probably the case when you run program in background), you can run it like this:
sbt run </dev/null >output-file &有关详细信息,请参见此答案.
See this answer for details.
编辑
好吧,现在这是一个难题.简短的答案:按以下方式运行sbt:
Ok, now that was a puzzle. Short answer: run sbt as follows:
setsid nohup sbt run &理论上:
sbt停止的原因是SIGTTOU信号的到达.在几种情况下,它会交付给后台进程,其中包括修改终端配置.这是我们的情况,因为根据strace -f sbt run &,sbt在引擎盖下做了很多黑魔法,如下所示:
The reason why sbt stops is arrival of SIGTTOU signal. It is delivered to background process in several cases, which include modifying terminal configuration. This is our case because according to strace -f sbt run &, sbt does a lot of black magic under the hood like this:
[pid 16600] execve("/usr/bin/sh", ["sh", "-c", "stty -g < /dev/tty"], [/* 75 vars */] <unfinished ...>要解决此问题,您可以在不同的会话中运行sbt,以将其与当前终端分离,这样它就不会打开/dev/tty并弄乱我们的终端.
To work this around, you can run sbt in a different session to detach it from current terminal, so that it won't open /dev/tty and mess with our terminal.
更多推荐
如何将sbt作为守护程序运行?
发布评论