nohup:忽略输入 - 这是什么意思?

sta*_*tar 27 nohup

我使用nohup了一段时间的命令

nohup bash life.bash > nohup.out 2> nohup.err &
Run Code Online (Sandbox Code Playgroud)

nohup.err文件中我总是有一行nohup: ignoring input. 你能帮我弄清楚它是什么意思吗?

Ste*_*itt 19

那只是nohup告诉你它的设置;它输出到它的标准错误,你已经重定向到nohup.err. 您可以通过重定向其标准输入来避免该消息:

nohup bash life.bash > nohup.out 2> nohup.err < /dev/null &
Run Code Online (Sandbox Code Playgroud)

nohup检查其标准输入、标准输出和标准错误以查看哪些连接到终端;如果它找到任何连接,它会适当地处理它们(忽略输入,将输出重定向到nohup.out,将错误重定向到标准输出),并告诉你它做了什么。如果它没有找到任何需要断开连接的东西,它本身就不会输出任何东西。


roa*_*ima 8

nohup 正在告诉你它在做什么,它忽略了输入。

如果你想避免这个消息,重定向标准输入/dev/null这样的

nohup bash life.bash </dev/null >nohup.out 2>nohup.err &
Run Code Online (Sandbox Code Playgroud)