我有4个bash脚本:
script1.sh
script2.sh
script3.sh
wrapper.sh
我希望script1.sh和script2.sh在后台运行. script1.sh和script2.sh应该同时运行(即使script1.sh失败,script2.sh也应该运行),反之亦然.我希望仅在script1.sh和script2.sh成功完成后才能运行script3.sh.
wrapper.sh脚本应运行所有3个脚本.
我该如何实现?
解决方法:
您可以这样使用warpper.sh:
#!/bin/bash
# execute script1.sh in background and save pid in $pid1
./script1.sh &
pid1=$!
# execute script2.sh in background and save pid in $pid2
./script2.sh &
pid2=$!
# do more work here...
# wait for both background jobs to finish and save their return status
wait $pid1 && wait $pid2 && ./script3.sh
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。