I want to run a program (google-chrome) in the background, but prevent it from outputting any messages to the terminal.
I tried doing this:
google-chrome 2>&1 1>/dev/null &
However, the terminal still fills up without messages like:
[5746:5746:0802/100534:ERROR:object_proxy.cc(532)] Failed to call method: org.chromium.Mtpd.EnumerateStorag...
What am I doing wrong? How do I redirect all the output to /dev/null
?
Redirection operators are evaluated left-to-right. what you did wrong was put
2>&1
first, which points2
to the same place as1
currently is pointed to which is the local terminal screen because you have not redirected1
yet. What you need to do is either of the following:or
The placement of the redirect operators in relation to the command does not matter. You can put them before or after the command.
In the section
Redirection
bash's reference manual says:To redirect both
stderr
andstdout
tofile
you should use the formWith regard to your case that means substitute
with
It seems that syntax is different:
See the devices for FD = 2 are different when
./a.out 1>/dev/null 2>&1
and./a.out 2>&1 1>/dev/null &
1) FD=2 points to /dev/null
2) FD=2 points to /dev/pts/43