bash nohup 是否跨管道工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26912092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does nohup work across a pipe?
提问by Jasmine Lognnes
If I do
如果我做
nohup cmd1 | cmd2 &
is that the same as
是不是一样
nohup "cmd1 | cmd2" &
?
?
I would like that I nohup
everything, as cmd1
will listen on port 8023.
我希望我的nohup
一切,因为cmd1
将在端口 8023 上侦听。
回答by Wolph
No, you need to add the nohup to the commands separately.
不,您需要单独将 nohup 添加到命令中。
Something like this is recommended:
推荐这样的东西:
nohup sh -c "cmd1 | cmd2" &
Or alternatively:
或者:
nohup $SHELL <<EOF &
cmd1 | cmd2
EOF
回答by Politank-Z
As an alternative to nohup
, I recommend
作为替代nohup
,我推荐
( cmd1 | cmd2 ) > logfile < /dev/null 2>&1 &
By rerouting stdin, stdout, and sterr from the terminal, this achieves much the same effect as nohup with a syntax that I, at least, prefer.
通过从终端重新路由 stdin、stdout 和 sterr,这使用至少我更喜欢的语法实现了与 nohup 几乎相同的效果。
回答by Onnonymous
You could start your pipe in a screen
session. Keystroke Ctrl-aand then dwill detach the screen session from your terminal. You can then safely exit your terminal; the pipe will continue to run. Use screen -r
to reconnect to the session again.
您可以在screen
会话中启动管道。击键Ctrl-a,然后d将屏幕会话与您的终端分离。然后您可以安全地退出终端;管道将继续运行。用于screen -r
再次重新连接到会话。
回答by Skynet
nohup cmd1 | cmd2 &
No, I have checked just now this is the as follows
不,我刚才查了一下,是这样的
nohup: ignoring input and redirecting stderr to stdout