我想将Linux中的后台应用程序生成的输出重定向到/dev/null.
I would like to redirect the output generated from a background application in Linux to /dev/null.
我正在使用kate文本编辑器,它将在我想重定向到/dev/null的终端上打印所有调试消息.
I am using kate text editor and it prints all the debug messages on the terminal which I would like to redirect to /dev/null.
有什么想法吗?
谢谢
推荐答案您使用:
yourcommand > /dev/null 2>&1如果应在后台运行,请添加&
If it should run in the Background add an &
yourcommand > /dev/null 2>&1 &>/dev/null 2>&1表示将stdout重定向到/dev/null并将stderr重定向到stdout当时指向的位置
>/dev/null 2>&1 means redirect stdout to /dev/null AND stderr to the place where stdout points at that time
如果您希望stderr出现在控制台上,并且只有stdout进入/dev/null,则可以使用:
If you want stderr to occur on console and only stdout going to /dev/null you can use:
yourcommand 2>&1 > /dev/null在这种情况下,stderr重定向到stdout(例如您的控制台),然后之后将原始的stdout重定向到/dev/null
In this case stderr is redirected to stdout (e.g. your console) and afterwards the original stdout is redirected to /dev/null
如果程序不应该终止,则可以使用:
If the program should not terminate you can use:
nohup yourcommand &没有任何参数,所有输出均落入nohup.out
Without any parameter all output lands in nohup.out
更多推荐
如何在后台将应用程序的输出重定向到/dev/null
发布评论