This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.sh
executable file
·65 lines (57 loc) · 1.54 KB
/
status.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#return code 0 = running
#return code 1 = finished successfully
#return code 2 = failed
##now wait for running to go away
#progress_url={$SCA_PROGRESS_URL}/{$SCA_PROGRESS_KEY}
if [ -f finished ]; then
code=`cat finished`
if [ $code -eq 0 ]; then
echo "finished successfully"
exit 1 #success!
else
echo "finished with code:$code"
exit 2 #failed
fi
fi
if [ -f jobid ]; then
jobid=`cat jobid`
if [ -z $jobid ]; then
echo "jobid is empty.. failed to submit?"
exit 3
fi
jobstate=`qstat -f $jobid | grep job_state | cut -b17`
if [ -z $jobstate ]; then
echo "Job removed before completing - maybe timed out?"
exit 2
fi
if [ $jobstate == "Q" ]; then
echo "Waiting in the queue"
eststart=`showstart $jobid | grep start`
[ -n "$SCA_PROGRESS_URL" ] && curl -s -X POST -H "Content-Type: application/json" -d "{\"msg\":\"Waiting in the PBS queue : $eststart\"}" $SCA_PROGRESS_URL > /dev/null
exit 0
fi
if [ $jobstate == "R" ]; then
echo "Running"
exit 0
fi
if [ $jobstate == "H" ]; then
echo "Job held.. waiting"
exit 0
fi
#assume failed for all other state
echo "Jobs failed - PBS job state: $jobstate"
exit 2
fi
if [ -f pid ]; then
if ps -p $(cat pid) > /dev/null
then
tail -1 stdout.log
exit 0
else
echo "no longer running but didn't finish"
exit 2
fi
fi
echo "can't determine the status - maybe not yet started?"
exit 3