1 |
mocchiut |
1.1 |
#!/bin/bash |
2 |
|
|
|
3 |
|
|
source /gpfs/wizard/flight/production/installed/set_pam_env.sh > /dev/null 2>&1; |
4 |
|
|
|
5 |
|
|
if [ "$PAM_BIN" == "" ]; then exit; fi |
6 |
|
|
|
7 |
|
|
export PRODDIR=/gpfs/wizard/flight/production/ |
8 |
|
|
|
9 |
|
|
export POSTRR=$PRODDIR/postRawreader/ |
10 |
|
|
|
11 |
|
|
export WRKDIR=$PRODDIR/deamons/wrkdir/ |
12 |
|
|
|
13 |
|
|
export LOGDIR=$PRODDIR/logs/ |
14 |
|
|
|
15 |
|
|
export SCRIPT=$PRODDIR/deamons/script/ |
16 |
|
|
|
17 |
|
|
touch $WRKDIR/yoda.yodalist |
18 |
|
|
|
19 |
|
|
LOG=$WRKDIR/yoda.log |
20 |
|
|
|
21 |
|
|
BUSY=$WRKDIR/yodalist.busy |
22 |
|
|
|
23 |
|
|
touch $LOG |
24 |
|
|
|
25 |
|
|
touch $BUSY |
26 |
|
|
|
27 |
|
|
echo -n " DEAMON STARTED AT " >> $LOG; |
28 |
|
|
|
29 |
|
|
date >> $LOG; |
30 |
|
|
|
31 |
|
|
echo "293" > $WRKDIR/yoda.step |
32 |
|
|
#echo "-300" > $WRKDIR/yoda.step |
33 |
|
|
|
34 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step`; |
35 |
|
|
|
36 |
|
|
while [ $TIME -gt 0 ]; do |
37 |
|
|
|
38 |
|
|
ls $LOGDIR/rr/good/rr.[0-9]*.log* > $WRKDIR/yoda.cln1list; |
39 |
|
|
### ls $LOGDIR/rr/good/rr.00110000.log* > $WRKDIR/yoda.cln1list; |
40 |
|
|
|
41 |
|
|
for nfile in `sort $WRKDIR/yoda.cln1list`; do |
42 |
|
|
|
43 |
|
|
DONE=0; |
44 |
|
|
|
45 |
|
|
bfile=`basename $nfile`; |
46 |
|
|
|
47 |
|
|
rfile=${bfile:3:5}; |
48 |
|
|
|
49 |
|
|
dfile=${bfile:8:3}; |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
for file in `ls $POSTRR/${rfile}_${dfile}_*_cln*.pam`; do |
53 |
|
|
|
54 |
|
|
for procfile in `cat $WRKDIR/yoda.yodalist`; do |
55 |
|
|
|
56 |
|
|
if [ $file == $procfile ]; then |
57 |
|
|
|
58 |
|
|
DONE=1; |
59 |
|
|
|
60 |
|
|
fi; |
61 |
|
|
|
62 |
|
|
done; |
63 |
|
|
|
64 |
|
|
if [ $DONE -eq 0 ]; then |
65 |
|
|
|
66 |
|
|
NOW=`date +%s` |
67 |
|
|
|
68 |
|
|
CTIME=`date --reference=$file +%s` |
69 |
|
|
|
70 |
|
|
let DELTA=NOW-CTIME |
71 |
|
|
|
72 |
|
|
if [ $DELTA -gt 300 ]; then |
73 |
|
|
|
74 |
|
|
echo -n "FILE IS COLD NOW: " >> $LOG; |
75 |
|
|
|
76 |
|
|
date >> $LOG; |
77 |
|
|
|
78 |
|
|
echo "NOW IS $NOW" >> $LOG; |
79 |
|
|
|
80 |
|
|
echo "LAST ACCESS TIME IS $CTIME" >> $LOG; |
81 |
|
|
|
82 |
|
|
echo "Processing file $file!" >> $LOG; |
83 |
|
|
|
84 |
|
|
NOME=`basename $file .pam` |
85 |
|
|
|
86 |
|
|
R=0; |
87 |
|
|
|
88 |
|
|
TEST="" |
89 |
|
|
|
90 |
|
|
while [ "$TEST" == "" ] && [ $R -lt 10 ]; do |
91 |
|
|
|
92 |
|
|
let R=$R+1; |
93 |
|
|
|
94 |
|
|
QUEUE=ts_wizard |
95 |
|
|
|
96 |
|
|
CHECK=`bhist -q "${QUEUE}" -p`; |
97 |
|
|
|
98 |
|
|
while [ "$CHECK" != "No matching job found" ]; do |
99 |
|
|
|
100 |
|
|
sleep 20; |
101 |
|
|
|
102 |
|
|
CHECK=`bhist -q "${QUEUE}" -p`; |
103 |
|
|
|
104 |
|
|
if [ "$CHECK" != "No matching job found" ]; then |
105 |
|
|
|
106 |
|
|
CHECK2=`bhist -q "normal" -p`; |
107 |
|
|
|
108 |
|
|
if [ "$CHECK2" == "No matching job found" ]; then |
109 |
|
|
|
110 |
|
|
echo " Using normal queue since ts_wizard is full " >> $LOG; |
111 |
|
|
|
112 |
|
|
QUEUE="normal"; |
113 |
|
|
|
114 |
|
|
CHECK=`bhist -q "${QUEUE}" -p`; |
115 |
|
|
|
116 |
|
|
fi; |
117 |
|
|
|
118 |
|
|
fi; |
119 |
|
|
|
120 |
|
|
done; |
121 |
|
|
|
122 |
|
|
SUBO=`bsub -q $QUEUE -oo $LOGDIR/yoda.lsf.$NOME.log $SCRIPT/yoda.sh $file`; |
123 |
|
|
|
124 |
|
|
echo " Output from LSF is: $SUBO " >> $LOG; |
125 |
|
|
|
126 |
|
|
TEST=`echo $SUBO | grep "is submitted"`; |
127 |
|
|
|
128 |
|
|
if [ "$TEST" == "" ]; then |
129 |
|
|
|
130 |
|
|
echo " Send LSF job failure! " >> $LOG; |
131 |
|
|
|
132 |
|
|
echo " Retry n. $R " >> $LOG; |
133 |
|
|
|
134 |
|
|
fi |
135 |
|
|
|
136 |
|
|
done |
137 |
|
|
|
138 |
|
|
if [ $R -ge 10 ]; then |
139 |
|
|
|
140 |
|
|
echo -n " PROBLEMS SENDING LSF JOBS! " >> $LOG; |
141 |
|
|
|
142 |
|
|
date >> $LOG; |
143 |
|
|
|
144 |
|
|
echo " File $file not processed yet, I will retry later " >> $LOG; |
145 |
|
|
|
146 |
|
|
else |
147 |
|
|
|
148 |
|
|
CHOK=`tail -1 $BUSY`; |
149 |
|
|
|
150 |
|
|
if [ "$CHOK" == "" ]; then |
151 |
|
|
|
152 |
|
|
echo "0" > $BUSY; |
153 |
|
|
|
154 |
|
|
CHOK=`tail -1 $BUSY`; |
155 |
|
|
|
156 |
|
|
fi |
157 |
|
|
|
158 |
|
|
while [ $CHOK -eq 1 ]; do |
159 |
|
|
|
160 |
|
|
echo -n " LIST FILE IS BUSY " >> $LOG; |
161 |
|
|
|
162 |
|
|
date >> $LOG; |
163 |
|
|
|
164 |
|
|
sleep 1; |
165 |
|
|
|
166 |
|
|
CHOK=`tail -1 $BUSY `; |
167 |
|
|
|
168 |
|
|
done |
169 |
|
|
|
170 |
|
|
echo "1" > $BUSY; |
171 |
|
|
|
172 |
|
|
echo $file >> $WRKDIR/yoda.yodalist; |
173 |
|
|
|
174 |
|
|
echo "0" > $BUSY; |
175 |
|
|
|
176 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
177 |
|
|
|
178 |
|
|
while [ $TIME -eq 1 ]; do |
179 |
|
|
|
180 |
|
|
echo -n " TIME = 1! DEAMON PAUSE " >> $LOG; |
181 |
|
|
|
182 |
|
|
date >> $LOG; |
183 |
|
|
|
184 |
|
|
sleep 120; |
185 |
|
|
|
186 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
187 |
|
|
|
188 |
|
|
done |
189 |
|
|
|
190 |
|
|
if [ $TIME -le 0 ]; then |
191 |
|
|
|
192 |
|
|
echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG; |
193 |
|
|
|
194 |
|
|
date >> $LOG; |
195 |
|
|
|
196 |
|
|
exit; |
197 |
|
|
|
198 |
|
|
fi; |
199 |
|
|
|
200 |
|
|
fi; |
201 |
|
|
|
202 |
|
|
fi; |
203 |
|
|
|
204 |
|
|
fi; |
205 |
|
|
|
206 |
|
|
done; |
207 |
|
|
|
208 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
209 |
|
|
|
210 |
|
|
while [ $TIME -eq 1 ]; do |
211 |
|
|
|
212 |
|
|
echo -n " TIME = 1! DEAMON PAUSE " >> $LOG; |
213 |
|
|
|
214 |
|
|
date >> $LOG; |
215 |
|
|
|
216 |
|
|
sleep 120; |
217 |
|
|
|
218 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
219 |
|
|
|
220 |
|
|
done; |
221 |
|
|
|
222 |
|
|
if [ $TIME -le 0 ]; then |
223 |
|
|
|
224 |
|
|
echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG; |
225 |
|
|
|
226 |
|
|
date >> $LOG; |
227 |
|
|
|
228 |
|
|
exit; |
229 |
|
|
|
230 |
|
|
fi |
231 |
|
|
|
232 |
|
|
done; |
233 |
|
|
|
234 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
235 |
|
|
|
236 |
|
|
while [ $TIME -eq 1 ]; do |
237 |
|
|
|
238 |
|
|
echo -n " TIME = 1! DEAMON PAUSE " >> $LOG; |
239 |
|
|
|
240 |
|
|
date >> $LOG; |
241 |
|
|
|
242 |
|
|
sleep 120; |
243 |
|
|
|
244 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
245 |
|
|
|
246 |
|
|
done |
247 |
|
|
|
248 |
|
|
if [ $TIME -le 0 ]; then |
249 |
|
|
|
250 |
|
|
echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG; |
251 |
|
|
|
252 |
|
|
date >> $LOG; |
253 |
|
|
|
254 |
|
|
exit; |
255 |
|
|
|
256 |
|
|
fi |
257 |
|
|
|
258 |
|
|
sleep $TIME; |
259 |
|
|
|
260 |
|
|
TIME=`tail -1 $WRKDIR/yoda.step `; |
261 |
|
|
|
262 |
|
|
done; |
263 |
|
|
|
264 |
|
|
echo -n " EXIT DEAMON, RECEIVED TERM SIGNAL " >> $LOG; |
265 |
|
|
|
266 |
|
|
date >> $LOG; |