I would like to use GNU Parallel to run N commands on P cores. I put each command in a file: ListOfCommand. Each line in that file corresponds to a different command and each line is the complete command that can be run 'as is' at the command-line. There are many more commands than cores. So I would like GNU Parallel to run only P commands at a time, and then whenever a command finishes running, the next command in the file should begin (dynamic scheduling).
It seems like this should be doable with GNU Parallel, but I'm having a hard time digesting the man page. Does anyone know how to do this?
[EDIT] After more digging, this seems to work:
parallel -P 4 '{}' < ListOfCommands
As regards supplying the list of commands, you should be able to use any of the following equivalently:
As regards what is run for each command in the list, you can use
{}to identify parameters, but if you specify no command to be run, the line from your file is taken as the command:So, if you make your
ListOfCommandslike this:You can run the following and the command to run for each job is the
echo Xline from your commands:If you just want to put the parameters for the command to run in a file, you write
ListOfParameterslike this:then put the
echocommand on the GNU Parallel command line itself as follows and use{}: