Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with output from a background linux task

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/s
Receiving 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!

like image 847
danivicario Avatar asked Jan 31 '13 16:01

danivicario


2 Answers

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 &

like image 145
nullrevolution Avatar answered Oct 14 '22 15:10

nullrevolution


The other answers are good, but you can also use:

git clone -q ...

See here for details.

like image 44
jman Avatar answered Oct 14 '22 15:10

jman