bash调用串行任务队列方法和干预
- 将任务填写在task_list以数组的形式组织
- for循环一步步的执行串行任务
- 某个任务需要依靠外部条件触发执行,monitor监测需要的文件
task_list=(task1 task2 task3)
function monitor() {
until test -e goal_file; do
echo "waitting for another task excute"
sleep 5s
done
}
for task in "${task_list[@]}"; do
case ${task} in
task1) echo "excute task1 command";;
task2) monitor
echo "excute task2 command";;
task3) echo "excute task3 command";;
*) echo "ILLEAGAL TASK"
exit;;
done