加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 在初始化/ bash脚本中同时执行多个程序

发布时间:2020-12-14 01:36:28 所属栏目:Linux 来源:网络整理
导读:您好我正在使用一个使用rcS脚本启动的模拟器,这是我的脚本 cd /tests./test1 ./test2 ./test3 ./test4 exit 我想要的是同时运行所有测试,并且只有在所有先前的测试完成后才执行exit命令.并且不仅在测试4完成时,这可能吗? 谢谢. 解决方法 你可以使用wait: .
您好我正在使用一个使用rcS脚本启动的模拟器,这是我的脚本

cd /tests
./test1 &
./test2 &
./test3 &
./test4 
exit

我想要的是同时运行所有测试,并且只有在所有先前的测试完成后才执行exit命令.并且不仅在测试4完成时,这可能吗?
谢谢.

解决方法

你可以使用wait:

./test1 &
./test2 &
./test3 &
./test4 &
wait

从bash手册页:

wait [n …] Wait for each specified process and return its termination status. Each n may be a process ID or a job specification; if a job spec is given,all processes in that job’s pipeline are waited for. If n is not given,all currently active child processes are waited for,and the return status is zero. If n specifies a non-existent process or job,the return status is 127. Otherwise,the return status is the exit status of the last process or job waited for.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读