Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using xargs to execute a command on a set of input parameters something like this:

cat <someinput> | xargs -n 1 -P 5 <somecmd>

The input file is really long and take a long time to run. So I'm just waiting for the command prompt to show up. Is there a way to display a progress bar for the number of input arguments that have completed?

I tried using 'bar' but I always got an 'infinite' throughput. It seems like xargs reads the entire input before executing commands.


share|improve this question

2 Answers 2

You can use pv :

cat <someinput> | pv -p -s sizeof_someimput | xargs -n 1 -P 5 <somecmd>

With this you will now where the reading of someimput is so you will know approximately where the treatment of someimput is.

share|improve this answer

If you have GNU Parallel you can run:

cat <someinput> | parallel --bar -P 5 <somecmd>

All new computers have multiple cores, but most programs are serial in nature and will therefore not use the multiple cores. However, many tasks are extremely parallelizeable:

  • Run the same program on many files
  • Run the same program for every line in a file
  • Run the same program for every block in a file

GNU Parallel is a general parallelizer and makes is easy to run jobs in parallel on the same machine or on multiple machines you have ssh access to.

If you have 32 different jobs you want to run on 4 CPUs, a straight forward way to parallelize is to run 8 jobs on each CPU:

Simple scheduling

GNU Parallel instead spawns a new process when one finishes - keeping the CPUs active and thus saving time:

GNU Parallel scheduling


A personal installation does not require root access. It can be done in 10 seconds by doing this:

(wget -O - pi.dk/3 || curl pi.dk/3/ || fetch -o - http://pi.dk/3) | bash

For other installation options see http://git.savannah.gnu.org/cgit/parallel.git/tree/README

Learn more

See more examples: http://www.gnu.org/software/parallel/man.html

Watch the intro videos: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

Walk through the tutorial: http://www.gnu.org/software/parallel/parallel_tutorial.html

Sign up for the email list to get support: https://lists.gnu.org/mailman/listinfo/parallel

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.