Functions and GNU parallel for effective cluster load management
I've been a fan of GNU parallel for a long time. Initially I was sceptical about using it, preferring to write huge for loops but over time I've grown to love it. The beauty of GNU parallel is that it spawns a specified number of jobs in parallel and then submits more jobs as others are completed. This means that you get maximum usage out of the CPUs without overloading the system. There are many excuses for not using it , but perhaps the only valid one is that you have Sun Grid Engine or another job scheduler or manager in place. GNU parallel is particularly useful when used with functions . Functions are subroutines that may be repeated many times to complete a piece of work. In bash, here is a simple example , which declares a function consisting of a chain of piped commands, and then executes 4 jobs in parallel, until all of *files.txt have been processed. #!/bin/bash my_func2() { INPUT=$1 VAR1=bar cmd1 $INPUT $VAR1 | cmd2 | cmd3 > ${1}.out } export -...