Retry a Bash command with timeout

前端 未结 5 642
情歌与酒
情歌与酒 2020-12-28 12:51

How to retry a bash command until its status is ok or until a timeout is reached?

My best shot (I\'m looking for something simpler):

NEXT_WAIT_TIME=0         


        
5条回答
  •  孤城傲影
    2020-12-28 13:35

    One line and shortest, and maybe the best approach:

    timeout 12h bash -c 'until ssh root@mynewvm; do sleep 10; done'
    

    Credited by http://jeromebelleman.gitlab.io/posts/devops/until/

提交回复
热议问题