如何从 bash 脚本并行运行多个程序? [英] How do you run multiple programs in parallel from a bash script?

查看:37
本文介绍了如何从 bash 脚本并行运行多个程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 .sh 文件,它同时运行多个程序

I am trying to write a .sh file that runs many programs simultaneously

我试过了

prog1 
prog2

但是它运行 prog1 然后等到 prog1 结束然后启动 prog2...

But that runs prog1 then waits until prog1 ends and then starts prog2...

那么我如何并行运行它们?

So how can I run them in parallel?

推荐答案

并行运行多个程序:

prog1 &
prog2 &

如果你需要你的脚本等待程序完成,你可以添加:

If you need your script to wait for the programs to finish, you can add:

wait

在您希望脚本等待它们的位置.

at the point where you want the script to wait for them.

这篇关于如何从 bash 脚本并行运行多个程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆