File: sleep_loop.sh

package info (click to toggle)
nwchem 7.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,134,820 kB
  • sloc: fortran: 4,903,090; ansic: 67,501; f90: 19,555; python: 17,912; java: 12,311; sh: 12,023; cpp: 9,896; perl: 6,123; csh: 4,345; makefile: 1,856; sed: 246; awk: 115; exp: 111; pascal: 76
file content (30 lines) | stat: -rwxr-xr-x 582 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/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