Search code examples
multithreadingterminalparallel-processinglimitgnu-parallel

GNU Parallel: limiting jobs does not work when using -n0 for constant/fixed parameters


Here is what I am trying to achieve. I want to use GNU Parallel to run nohup example.py fixedparam & 10 times, but limiting it to 3 jobs. I want it to always be run with the exact same parameters, so I use -N0.

Currently, for testing, example.py is simply:

import os
import time

time.sleep(10)

Then here is how I am calling it with GNU Parallel:

seq 10 | parallel -j3 -N0 "nohup example.py &"

The problem is that the number of jobs ends up not being restricted to 3. As you can see by the partial screenshot I took from my terminal after calling top:

enter image description here

What am I doing wrong? How can I repeat in parallel the execution of example.py with fixed parameters using -N0 but still limit the execution to a given number of jobs?


Solution

  • Actually, I found that the correct thing to do in my case is:

    nohup seq 10 | parallel -j3 -N0 "python example.py" &