NWChem/travis/sleep_loop.sh
Yuri Victorovich 7b3d60dce7 Fix bash shebangs: make /usr/bin/env find bash in paths
This is needed on FreeBSD and other systems where bash isn't located in /bin/bash.
2021-11-07 14:06:22 -08:00

30 lines
590 B
Bash
Executable file

#!/usr/bin/env bash
rm -f make.log
echo "starting sleep_loop.sh for command: " ${@}
"${@}" >& make.log &
pid=$!
echo "sleep_loop got pid" $pid
sleep 1
ps -p "$pid" > /dev/null
if [[ "${?}" -ne 0 ]];
then
echo ' job stopped ' "${?}"
exit 1
else
while :
do
ps -p "$pid" > /dev/null
ps_exit="${?}"
if [[ "$ps_exit" -eq 0 ]]; then
echo ' ==== ' `date` ' ==== '
tail -1 make.log
elif [[ "$ps_exit" -ne 0 ]]; then
break # exit loop.
fi
sleep 10s
done
exit 0
fi
echo 'exited loop '
tail -1 make.log