Monday, September 2, 2013

Redirect the output generated from a background application in Linux to /dev/null.

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 wherestdout points at that time

If you want stderr to occure 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 stdoutis redirected to /dev/null

If the program should not terminate you can use:
nohup yourcommand &

Without any parameter all output lands in nohup.out

No comments:

Post a Comment