Created
September 9, 2013 13:34
-
-
Save ironsmile/6495642 to your computer and use it in GitHub Desktop.
repeats a command as long as its execution is more than 3 seconds
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 | |
while [[ true ]]; do | |
echo "[`date`] Repeating $1" | |
START=`date +%s` | |
$1 | |
END=`date +%s` | |
DURATION=`echo "$END-$START" | bc` | |
if [[ $DURATION -lt 3 ]]; then | |
echo "Command $1 run for less than 3 seconds. Aborting." | |
exit | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment