Linux – How to deal with output from a background linux task

background-process, bash, command-line, linux

I have a task that is continuously echoing info.

For example, if you do a git clone and you want to send that task to the background (by using ampersand)

git clone https://github.com/mrdoob/three.js.git &

then the git clone operation is constantly refreshing the screen with the new percentage of the git clone process, ie:

Receiving objects:  47% (22332/47018), 92.53 MiB | 480 KiB/s   1410/47018), 7.18 MiB | 185 KiB/sReceiving objects:  53% (24937/47018), 99.40 MiB | 425 KiB/s   1410/47018), 7.18 MiB | 185 KiB/s 

So I cannot continue doing other operations in the foreground, as these updates are preventing me to see what I am trying to write.

Can you tell me guys how to effectively send one verbose task like this to the background?

Thanks a lot!

Best Solution

you could have the process write its output to a file (if you need to view it later) like this:

git clone https://github.com/mrdoob/three.js.git >output.txt &

or discard the output altogether like this:

git clone https://github.com/mrdoob/three.js.git >/dev/null &

edit:

you could also include any error messages sent to stderror in either of the above options by replacing the & with 2>&1 &