如何将应用程序的输出在后台重定向到/ dev / null(How to redirect the output of an application in background to /dev/nul

编程入门 行业动态 更新时间:2024-10-28 02:27:05
如何将应用程序的输出在后台重定向到/ dev / null(How to redirect the output of an application in background to /dev/null)

我想将从Linux中的后台应用程序生成的输出重定向到/ dev / null。

我正在使用kate文本编辑器,它打印终端上的所有调试消息,我想重定向到/ dev / null。

有什么想法怎么办?

谢谢

I would like to redirect the output generated from a background application in Linux to /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.

Any idea how to do it ?

Thanks

最满意答案

你用:

yourcommand > /dev/null 2>&1

如果它应该在后台运行添加&

yourcommand > /dev/null 2>&1 &

>/dev/null 2>&1意味着将stdout重定向到/dev/null AND stderr到stdout指向的地方

如果你想要stderr发生在控制台,只有stdout进入/dev/null你可以使用:

yourcommand 2>&1 > /dev/null

在这种情况下, stderr被重定向到stdout (例如你的控制台), 然后原始stdout被重定向到/dev/null

如果程序不能终止,可以使用:

nohup yourcommand &

没有任何参数,所有输出都在nohup.out中

You use:

yourcommand > /dev/null 2>&1

If it should run in the Background add an &

yourcommand > /dev/null 2>&1 &

>/dev/null 2>&1 means redirect stdout to /dev/null AND stderr to the place where stdout points at that time

If you want stderr to occur on console and only stdout going to /dev/null you can use:

yourcommand 2>&1 > /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 &

Without any parameter all output lands in nohup.out

更多推荐

本文发布于:2023-08-02 19:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1380040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   应用程序   重定向   后台   dev

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!