Search code examples
gnu-parallel

GNU Parallel - multiple commands


I'd like to run several long-running processes on several inputs. E.g.:

solver_a problem_1
solver_b problem_1
...
solver_b problem_18
solver_c problem_18

I know how to run multiple arguments for the same command - that is the core use case. This is more like the opposite case: multiple commands for the same argument.

Of course you could always run multiple instances of parallel - but then are the instances on the same machines or under the same user aware of each other when scheduling resources?


Solution

  • I think you want GNU Parallel to run each of 18 problems through each of 3 solvers:

    parallel echo solver_{1} problem_{2} ::: {a..c} ::: {1..18}
    

    Sample Output

    solver_a problem_1
    solver_a problem_2
    solver_a problem_3
    solver_a problem_4
    ...
    ...
    solver_c problem_16
    solver_c problem_17
    solver_c problem_18
    

    Or, changing the other parameter faster:

    parallel echo solver_{2} problem_{1} ::: {1..18} ::: {a..c}