0

I have a for loop in a shell script that runs like:

for ((i=1; i<=N; i++))
 do
   eval $cmd
   wait
 done

and my issue is that $cmd is in the form:

numactl --physcpu=0-0 --membind=0 [SCRIPT] &
numactl --physcpu=1-1 --membind=0 [SCRIPT] &
numactl --physcpu=2-2 --membind=0 [SCRIPT] &
...
numactl --physcpu=20-20 --membind=0 [SCRIPT] 

Which of these processes does the WAIT command wait to finish? Is it all of them? If not, how should I go about making it so that each iteration of the forloop only runs after all 20 instances of SCRIPT are finished?

manatee
  • 15
  • 4
  • `wait` with no args waits on **all** spawned processes to finish – Serge Feb 14 '20 at 02:05
  • 1
    The `eval` won't return until the final `numactl` finishes ( as it hasn't been backgrounded). You should background that one too. That's all you need to change. Run `help wait` for some information on syntax. – jhnc Feb 14 '20 at 03:01

0 Answers0