RSS Amplifier

Home | BackEndTea · Aug 5, 2024

Keep retrying a bash command until it fails

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

This week I noticed a test was flaky, and was occasionally failing in CI. So I wanted to re-run my script until it failed. I had no clue how to do this, so after a bit of trying, I got the following script. This keeps running vendor/bin/phpunit until it fails. You can save it as run.sh and then just run sh ./run.sh in your terminal, and it will keep running. #!/bin/sh set -e while [ true ] do…

This week I noticed a test was flaky, and was occasionally failing in CI. So I wanted to re-run my script until it failed.

I had no clue how to do this, so after a bit of trying, I got the following script. This keeps running vendor/bin/phpunit until it fails. You can save it as run.sh and then just run sh ./run.sh in your terminal, and it will keep running.

#!/bin/sh

set -e
while [ true ] do
 vendor/bin/phpunit
done

If you want to get notified of the next blog post, join the newsletter.

Read on backendtea.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.