Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You can use pv :

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

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

share|improve this answer
Another frequent use-case might be the combination with find: FIND=( find "$DIR" -type f ) && ${FIND[@]} -print0 | pv -0lps $(${FIND[@]} | wc -l) | xargs -0 -I {} -P 5 <somecmd> – mxmlnkn May 14 at 0:09

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 - || curl || fetch -o - | bash

For other installation options see

Learn more

See more examples:

Watch the intro videos:

Walk through the tutorial:

Sign up for the email list to get support:

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.