本文介绍了nohup 重定向命令区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面这两行有什么区别?

What is the difference between these 2 below lines?

nohup $CATALINA_HOME/bin/startup.sh $CATALINA_HOME 2> /dev/null &

nohup $CATALINA_HOME/bin/startup.sh $CATALINA_HOME > /dev/null &

我的 2 个项目中有这些行,其中包含 Tomcat 服务器.其中之一是有 2> &另一个只是带有 > 符号.

I've these lines in 2 of my projects having Tomcat server. One of them is having 2> & other one is just with > symbol.

感谢您的帮助!

注意:如果在 CentOS 中运行,带有 2> 的行运行良好,但另一行给出警告:nohup: redirecting stderr to stdout"

Note: The line with 2> if ran in CentOS runs fine but the other one gives warning: "nohup: redirecting stderr to stdout"

谢谢!

推荐答案

都重定向到 /dev/null 第一个重定向 stderr 第二个重定向 标准输出.

Both redirect to /dev/null the first one redirects stderr the second one redirects stdout.

更多相关信息:http://www.tldp.org/LDP/abs/html/io-redirection.html,还有一些总是来自 tldp 的例子 http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html

More on that: http://www.tldp.org/LDP/abs/html/io-redirection.html, also a few examples always from tldp http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html

旁注:如果你想同时重定向 stdoutstderr 你可以这样做:

Side note: if you want to redirect both stdout and stderr you could do:

nohup $CATALINA_HOME/bin/startup.sh $CATALINA_HOME &> /dev/null &

这篇关于nohup 重定向命令区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 08:19