必须用nohup命中输入

Dre*_*eur 8 linux

我有这样的shell命令

sudo nohup coffee -c -w *.coffee &
disown $!
wait
Run Code Online (Sandbox Code Playgroud)

但是当我运行shell scrit时它会说nohup: appending output to 'nohup.out'并让我进入.如何绕过进入?

nin*_*ing 7

8 岁的线程,但我发现这些答案都没有真正解决问题中的问题。

该消息nohup: ignoring input and appending output to 'nohup.out'通过 stderr (AFAIK) 传送,因此为了使该消息静音,您所要做的就是将 stderr 重定向到/dev/null,如下所示:

nohup mycommand 2> /dev/null
Run Code Online (Sandbox Code Playgroud)

但是,如果您还想在后台使用 运行此进程&,您会发现(至少对于 bash),将有一行输出作业编号和 PID(例如[1] 27184)。为避免这种情况,请在子 shell 中运行整个命令,如下所示:

(nohup my command 2> /dev/null &)
Run Code Online (Sandbox Code Playgroud)

但是如果你在脚本中使用它,前一个解决方案就足够了。


Vla*_*lad 6

据我所知,你没有必要.消息输出到控制台,但不会添加到输入缓冲区.因此,您可以继续键入命令,就像没有消息一样nohup,消息不会干扰您的输入.

那么,不必从确切的提示位置打字可能在审美上不那么令人愉快.