如何使用bash脚本并行启动两个程序

时间:2018-04-17 21:18:42

标签: bash

我有什么:

#!/bin/bash
cd App && exp start
cd ~/Android/Sdk/emulator ./emulator &

但这只是开始exp。我希望它启动exp打开另一个bash终端并在那里启动模拟器。有什么提示吗?

2 个答案:

答案 0 :(得分:3)

在这里: -

#!/bin/bash
cd App || exit
#better always put a full path like /home/App/
exp start &
cd ~/Android/Sdk/emulator || exit
#better always put a full path 
./emulator &

如果你想要等到两个进程完成等待脚本结束

答案 1 :(得分:0)

你可以使用例如nohup 像:

#!/bin/bash
cd App 
nohup exp start > exp.log 2> exp.error.log &
cd ~/Android/Sdk/emulator 
nohup ./emulator > emulator.log 2> emulator.error.log &

类似的东西