BasH:在后台运行脚本

时间:2014-02-12 00:20:50

标签: linux bash shell

我正在尝试在后台运行两个脚本。但是我想首先运行一个脚本,等待它完成并递归地运行下一个脚本。这段代码片段会这样做吗:

for i in "${studyinstanceuids[@]}"
do
#let count="$count+1"
echo "$i" | ./cmd2&
sleep 5
if job1 is alive then sleep 5
      echo "$i" | ./sendExamToRepo.sh&
      wait
fi

1 个答案:

答案 0 :(得分:0)

for i in "${studyinstanceuids[@]}"; do
    ( echo "$i" | ./cmd2; echo "$1" | ./sendExamToRepo.sh )&
done
wait