美文网首页
【Shell Script】当执行不成功时无限循环执行并记录尝试

【Shell Script】当执行不成功时无限循环执行并记录尝试

作者: Lyudmilalala | 来源:发表于2021-04-27 00:23 被阅读0次
    n=0
    brew install opencv // command you would like to repeat
    while  [ $? -ne 0 ]
    do
        (( n++ ))
        echo "Try to install opencv $n times"
        date +"[%D,%R] install opencv failed"
        brew install opencv  // command you would like to repeat
    done
    (( n++ ))
    echo "Try to install opencv $n times"
    date +"[%D,%R] install opencv sucess"
    
    # m=0
    # pip install pygame
    # while  [ $? -ne 0 ]
    # do
    #     (( m++ ))
    #     echo "Try to install pygame $m times"
    #     date +"[%D,%R] install pygame failed"
    #     pip install pygame
    # done
    # echo "Try to install pygame $m times"
    # date +"[%D,%R] install pygame sucess"
    

    相关文章

      网友评论

          本文标题:【Shell Script】当执行不成功时无限循环执行并记录尝试

          本文链接:https://www.haomeiwen.com/subject/tjnyrltx.html