Created
March 4, 2014 16:17
-
-
Save rch850/9349575 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh -eu | |
timeout=30 | |
since=15 | |
function usage() { | |
cat >&2<<EOT | |
Usage: $(basename $0) [-s since] [-t timeout] PATH... | |
EOT | |
} | |
# parse options http://qiita.com/b4b4r07/items/dcd6be0bb9c9185475bb | |
for OPT in "$@" | |
do | |
case "$OPT" in | |
'-h'|'--help') | |
usage | |
exit 1 | |
;; | |
'-s') | |
[ -z "$2" ] && { usage; exit 10; } | |
since=$2 | |
shift 2 | |
;; | |
'-t') | |
[ -z "$2" ] && { usage; exit 10; } | |
timeout=$2 | |
shift 2 | |
;; | |
esac | |
done | |
[ $# -eq 0 ] && { usage; exit 11; } | |
since=$(echo "scale=2; $since / 60" | bc) | |
echo -n "waiting for $1 stops" | |
for (( i = 0; i < $timeout; i++ )); do | |
echo -n "." | |
[ $(find $@ -mmin -$since | wc -l) -eq 0 ] && echo stopped && exit | |
sleep 1 | |
done | |
echo timeout!! | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment