Last active
April 26, 2019 06:51
-
-
Save EvanTheB/8f9e07746af0c84831fc17f94ac4672d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -euo pipefail | |
CACHE_FILE="$HOME"/.cache/qstat.map | |
# a 1 minute timed cache | |
# does not actually handle failures properly. todo | |
if ! test -e $CACHE_FILE || (( $(find "$CACHE_FILE" -mmin +1 | wc -l) > 0)); then | |
CACHE_FILE_TMP="$CACHE_FILE.$$.$RANDOM" | |
trap 'rm '"$CACHE_FILE_TMP" EXIT | |
qstat | awk '$3 ~ /cromwell/{print $1}' > "$CACHE_FILE_TMP" | |
mv "$CACHE_FILE_TMP" "$CACHE_FILE" | |
trap '' EXIT | |
fi | |
grep -q '^'"$1"'$' "$CACHE_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just realised this wont deal with brand new jobs very well - need the cache duraction to be shorter than the check-alive interval. (and hope check-alive is called AFTER an interval, not straight after qsub)