I have a program ./pgm
taking some arguments (say -a file1 -b val
), which requires 2 seconds to execute. I would like to use all the processors on my machine to run this program on all the input files in parallel (about 1000). What I do now, is put all the commands
./pgm -a file1 -b 12 > out1.txt &
./pgm -a file2 -b 14 > out2.txt &
./pgm -a file3 -b 16 > out3.txt &
./pgm -a file4 -b 18 > out4.txt &
...
in a file, and execute this file. I thought this would use all the available processors, but the number of parallel execution is very limited.
How can I achieve this? Note that parallel
command is not an option.
vmstat 1 1
in a second terminal whilst other is running for a few secconds would give you a rough idea. – X Tian Feb 18 '14 at 15:03vmstat
givesbo=1
. Does this explains why when I runxargs
with-P8
there is only one process running sometime? – wwjoze Feb 19 '14 at 00:11vmstat 1 1
is not useful because it gives you the average statistics since the system booted.vmstat 3
(oriostat -z 3
) to get running statistics every 3 seconds. Did you add the-n1
toxargs
. You don't have to installparallel
system-wide to use it, you can put it somewhere in your home directory. – Stéphane Chazelas Feb 19 '14 at 06:53