Last active
May 26, 2018 22:19
-
-
Save ms1995/11a2b960c3e2934fe8d6ca67216e2069 to your computer and use it in GitHub Desktop.
Automatically re-run a process after it exits. Usage: auto-rerun.sh INTERVAL CMD [ARGS...]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
running=1 | |
finish() { | |
running=0 | |
} | |
trap finish SIGINT | |
CMD="${@:2}" | |
while (( running )); do | |
$CMD | |
echo "Trying to re-run $CMD in $1 second(s)..." | |
sleep $1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment