我正在使用嵌套的 shell 脚本。
我的问题和问的有点相似here和 here .但不完全一样。
我试图从这些中得到解决方案但没有成功。
在我的 OuterMostShellScript.sh 中,我执行如下操作:
some commands
./runThisScriptX.sh
other commands
end of script.
runThisScriptX.sh 包含使用 &
运算符在后台运行某些进程的循环。
我希望每个由 ./runThisScriptX.sh
命令启动的进程在控件移动到我在上面的代码中所说的 other commands
行之前完成。
如何实现?
编辑:我也这样做了:
some commands
./runThisScriptX.sh
wait
other commands
end of script.
但是没有用。
最佳答案
两件事:
- 找到你的脚本
- 使用
等待
你的脚本不会像这样:
some commands
. ./runThisScriptX.sh # Note the leading . followed by space
wait # This would wait for the sourced script to finish
other commands
end of script
关于linux - 如何等到 shell 脚本启动的所有内容结束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23066630/