-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcheck-jobs.sh
executable file
·68 lines (48 loc) · 1.36 KB
/
check-jobs.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
65
66
67
68
#!/bin/bash
# How to use check-jobs.sh
#-------------------------------------------------------------------------------
if [ $# -lt 1 ]; then
echo " "
echo " Check the status of the jobs"
echo " "
echo " ./check-jobs.sh 0"
echo " "
echo " Print the list of failed files and remove the corresponding STDOUT"
echo " "
echo " ./check-jobs.sh 1"
echo " "
exit -1
fi
export OPTION=$1
export NPEND=`bjobs | grep PEND | wc -l`
export NRUN=`bjobs | grep RUN | wc -l`
export NFINISH=0
export NGOOD=0
if [ -d "jobs" ]; then
NFINISH=`ls jobs/LSFJOB_*/STDOUT | wc -l`
NGOOD=`cat jobs/LSFJOB_*/STDOUT | grep Done | wc -l`
fi
# Check the status of the jobs
#-------------------------------------------------------------------------------
printf " \n"
printf " %3d jobs pending\n" $NPEND
printf " %3d jobs running\n" $NRUN
printf " %3d jobs finished\n" $NFINISH
printf " %3d jobs successful\n" $NGOOD
printf " \n"
if [ $NGOOD -ne $NFINISH ]; then
printf " The following jobs have failed\n\n"
for fn in `ls jobs/LSFJOB_*/STDOUT`; do
export ISDONE=`cat $fn | grep Done | wc -l`
if [ $ISDONE -ne 1 ]; then
printf " %s\n" $fn
export FILENAME=`cat $fn | grep '/eos/'`
echo $FILENAME
echo " "
if [ "$OPTION" -eq "1" ]; then
rm -rf $fn
fi
fi
done
printf " \n"
fi