I have trouble understanding my situation and Google was not very helpful so far.
I started a bash background job:
ping google.com &
First I get the process ID, than Bash prints stdout to screen.
user@host:~$ ping google.com &
[1] 14004
user@host:~$ PING google.com (173.194.44.66) 56(84) bytes of data.
64 bytes from ham02s14-in-f2.1e100.net (173.194.44.66): icmp_seq=1 ttl=54 time=26.3 ms
64 bytes from ham02s14-in-f2.1e100.net (173.194.44.66): icmp_seq=2 ttl=54 time=27.4 ms
64 bytes from ham02s14-in-f2.1e100.net (173.194.44.66): icmp_seq=3 ttl=54 time=29.2 ms
...
This contradicts everything I read today. I have a standard Debian Jessie setup running GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu).
Can anyone explain this to me? Thanks.
Best Answer
By default, at least for POSIX compliant systems, running a command in background, with
&
, only detachesstdin
, so you'll be able to run other commands.stdout
andstderr
are still attached to the parent shell.If you don't want to see
stdout
and/orstderr
you can just redirect them to a file or/dev/null
: