标签:while res lang done The turn ret 输出 pre
#!/bin/bash
repeat() { while :; do $@ && return; sleep 1; done }
retryuntil() {
echo $(date +%F%n%T)
msg=`./job.sh 2>&1`
echo $msg
#echo "$msg" >> info.txt
result=$(echo "$msg" | grep "ERR")
if [[ "$result" != "" ]]
then
echo "Failed! Retry!"
return 1
else
echo "Done!"
return 0
fi
}
repeat retryuntil
npm i
在job中进行操作,do.sh
中根据job.sh
的输出信息判定是否成功,失败重试。
标签:while res lang done The turn ret 输出 pre
原文地址:https://www.cnblogs.com/Searchor/p/13495430.html