如何重试bash命令直到其状态正常或达到超时?
我最好的镜头(我正在寻找更简单的东西):
NEXT_WAIT_TIME=0 COMMAND_STATUS=1 until [ $COMMAND_STATUS -eq 0 || $NEXT_WAIT_TIME -eq 4 ]; do command COMMAND_STATUS=$? sleep $NEXT_WAIT_TIME let NEXT_WAIT_TIME=NEXT_WAIT_TIME+1 done
您可以通过在测试中放置命令并稍微改变一点来简化一些事情.否则脚本看起来很好:
原文链接:https://www.f2er.com/bash/387158.htmlNEXT_WAIT_TIME=0 until command || [ $NEXT_WAIT_TIME -eq 4 ]; do sleep $(( NEXT_WAIT_TIME++ )) done