linux下使用脚本反复重试一个命令

来源:https://unix.stackexchange.com/questions/82598/how-do-i-write-a-retry-logic-in-script-to-keep-retrying-to-run-it-upto-5-times/82610

n=0
until [ $n -ge 5 ]
do
  command && break
  n=$[$n+1]
  sleep 15
done

根据下面的表格替换上文中的内容

替换内容 功能
5 重试次数
command 想要重试的命令
15 重试前等待的时间

猜你喜欢

转载自www.cnblogs.com/gggear/p/10428952.html