Running bash commands in the background without printing job and process ids

Alex Spurling picture Alex Spurling · Oct 7, 2011 · Viewed 38.4k times · Source

To run a process in the background in bash is fairly easy.

$ echo "Hello I'm a background task" &
[1] 2076
Hello I'm a background task
[1]+  Done                    echo "Hello I'm a background task"

However the output is verbose. On the first line is printed the job id and process id of the background task, then we have the output of the command, finally we have the job id, its status and the command which triggered the job.

Is there a way to suppress the output of running a background task such that the output looks exactly as it would without the ampersand at the end? I.e:

$ echo "Hello I'm a background task" &
Hello I'm a background task

The reason I ask is that I want to run a background process as part of a tab-completion command so the output of that command must be uninterrupted to make any sense.

Answer

Dimitre Radoulov picture Dimitre Radoulov · Oct 7, 2011

Not related to completion, but you could supress that output by putting the call in a subshell:

(echo "Hello I'm a background task" &)