Files
q-tools/anduril/slurm-cake
2014-09-12 13:10:30 +03:00

28 lines
476 B
Bash
Executable File

#!/bin/bash
[ -z "$2" ] && { echo 'Usage: $0 "file" "some" "command"
Runs the command when file exists. waits for max 5 minutes'
return
}
fname="$1"
shift 1
otime=1
while :
do [ -e "$fname" ] || {
echo -n "File: $fname not found! "
date
}
[ -e "$fname" ] && {
break
}
otime=$(( $otime + 1 ))
sleep 1
[ $otime -gt 300 ] && {
echo "File $fname still missing after 5 minutes!"
exit 1
}
done
eval "$@"