Skip to content

Instantly share code, notes, and snippets.

@ironsmile
Created September 9, 2013 13:34
Show Gist options
  • Save ironsmile/6495642 to your computer and use it in GitHub Desktop.
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
#!/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