forked from piedraj/AnalysisCMS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check-jobs.sh
executable file
·83 lines (60 loc) · 1.88 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/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 creates samples_to_resubmit.txt on your current directory"
echo " "
echo " Remove the bad jobs"
echo " "
echo " ./check-jobs.sh 1"
echo " "
echo " Move the bad jobs to a new folder Badjobs"
echo " "
echo " ./check-jobs.sh 2"
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
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 >> _mid_samples_to_resubmit.txt
echo $FILENAME
echo " "
if [ "$OPTION" -eq "1" ]; then
rm -rf $fn
fi
fi
done
sed 's/filename: //g' _mid_samples_to_resubmit.txt > samples_to_resubmit.txt
rm _mid_samples_to_resubmit.txt
if [ "$OPTION" -eq "2" ]; then
mkdir -p BadJobs
mv `find $(grep -L Done jobs/LSFJOB_*/STDOUT ) -name STDOUT -printf '%h\n'` BadJobs/.
fi
printf " \n"
fi