我正在写一个脚本,但我需要一些东西,但我找不到方法来做到这一点......
我需要在后台“command1 &”中创建一个命令,然后在脚本中的某个地方我需要等待它完成,然后再执行 command2。基本上,我需要这个:
注意:每个命令都在特定目录中运行!在 while 循环结束时,我的 command1 创建了 4 个目录,其中每个目录运行特定进程,因此运行的进程总数为 4
a=1
while [$a -lt 4 ]
. command1
#Generates 1 Process
a= `export $a +1`
done
#Wait until the 4 process end and then run the command2
. command2
Run Code Online (Sandbox Code Playgroud)
我已经看到有关wait
带有 pid 进程号的命令的内容,但这也不起作用。