#!/usr/bin/env bash set -u # Script Name: trynafail # Description: Run command until it fails (every 0.5s) # Source: https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/ # Credit: Evan Hahn - https://codeberg.org/EvanHahn/dotfiles # Usage: trynafail nc -zv localhost 8080 # monitor until service dies # trynafail curl -sf https://api.example.com/health "$@" while [[ "$?" -eq 0 ]]; do sleep 0.5 "$@" done