首页 > 解决方案 > 等待命令使用什么进程来确定完成了哪个进程?

问题描述

我在 shell 脚本中有一个 for 循环,运行如下:

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

我的问题是 $cmd 的形式是:

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] 

WAIT 命令等待完成以下哪些进程?都是他们吗?如果不是,我应该如何去做,以便 forloop 的每次迭代只在所有 20 个 SCRIPT 实例完成后运行?

标签: bashmultithreadingshellthread-safetymulti-instance-deployment

解决方案


推荐阅读