retry until

Posted searchor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了retry until相关的知识,希望对你有一定的参考价值。

do.sh

#!/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

job.sh

npm i

在job中进行操作,do.sh中根据job.sh的输出信息判定是否成功,失败重试。

以上是关于retry until的主要内容,如果未能解决你的问题,请参考以下文章