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

2021-04-27  本文已影响0人  Lyudmilalala
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"
上一篇下一篇

猜你喜欢

热点阅读