首页 > 解决方案 > bash - 执行多个进程,然后执行另一个

问题描述

我正在尝试做类似以下的事情:

(task1 & task2) && echo "finished task1 and task2" && task3

目标是task1andtask2将同时执行,一旦 BOTH 完成,后一个命令将被执行(echo然后task3

那可能吗?

标签: bashubuntu

解决方案


只需使用:

task1 &
task2 &
wait         # for both task1 and task2 to finish
echo "finished task1 and task2"
task3

推荐阅读