1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This a script, which launches other scripts (all scripts, that are run
|
---|
28 | # on primary basis
|
---|
29 | #
|
---|
30 |
|
---|
31 |
|
---|
32 | source `dirname $0`/sourcefile
|
---|
33 | user=`whoami`
|
---|
34 |
|
---|
35 | notcount=0
|
---|
36 | while (( $notcount < 100 ))
|
---|
37 | do
|
---|
38 | for (( i=0 ; i < ${#scripts[@]} ; i++ ))
|
---|
39 | do
|
---|
40 | makedir $jmlogpath
|
---|
41 | date >> $jmscriptlog 2>&1
|
---|
42 | echo "sleeping $sleeptime..." >> $jmscriptlog 2>&1
|
---|
43 | sleep $sleeptime
|
---|
44 | dayofweek=`date +%u`
|
---|
45 | hour=`date +%k`
|
---|
46 | source `dirname $0`/sourcefile
|
---|
47 | echo "script: ${scripts[$i]}" >> $jmscriptlog 2>&1
|
---|
48 | # echo " day: $dayofweek hour: $hour" >> $jmscriptlog 2>&1
|
---|
49 | queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
|
---|
50 | queued=`setzero $queued`
|
---|
51 | queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
|
---|
52 | queuedscript=`setzero $queuedscript`
|
---|
53 |
|
---|
54 | pnototal=${pnototal[$hour]}
|
---|
55 | #choose array according to the day of the week
|
---|
56 | case $dayofweek in
|
---|
57 | 0 | 6) pnos=( ${pnoswe[@]} ) ;;
|
---|
58 | *) pnos=( ${pnosweek[@]} ) ;;
|
---|
59 | esac
|
---|
60 | num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
|
---|
61 | pnoscript=${pnos[$num]}
|
---|
62 | echo " found $queued jobs in the queue (incl. running jobs) [allowed $pnototal]" >> $jmscriptlog 2>&1
|
---|
63 | echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs) [allowed $pnoscript]" >> $jmscriptlog 2>&1
|
---|
64 | # echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" >> $jmscriptlog 2>&1
|
---|
65 |
|
---|
66 | if [ "$queued" -gt "$pnototal" ]
|
---|
67 | then
|
---|
68 | continue
|
---|
69 | else
|
---|
70 | if [ "$queuedscript" -gt "$pnoscript" ]
|
---|
71 | then
|
---|
72 | continue
|
---|
73 | fi
|
---|
74 | fi
|
---|
75 |
|
---|
76 | # get todofile
|
---|
77 | lockfile=$lockpath/lock-getting-${scripts[$i]}-list.txt
|
---|
78 | checklock >> $jmscriptlog 2>&1
|
---|
79 | singleprocess="yes"
|
---|
80 | gettodo
|
---|
81 | rm -v $lockfile >> $jmscriptlog 2>&1
|
---|
82 |
|
---|
83 | date=`date +%Y/%m/%d`
|
---|
84 | date2=`date +%Y-%m-%d`
|
---|
85 | condordir=$logpath/condor/$date
|
---|
86 | makedir $condordir >> $jmscriptlog 2>&1
|
---|
87 |
|
---|
88 | if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date2 -a dir=$condordir $scriptspath/run.condor 2>$jmerrorlog
|
---|
89 | then
|
---|
90 | date >> $jmerrorlog
|
---|
91 | nail -s 'condor problem' $erradrs < $jmerrorlog
|
---|
92 | echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
|
---|
93 | sleep $errorsleeptime
|
---|
94 | fi
|
---|
95 | echo "" >> $jmscriptlog 2>&1
|
---|
96 | done
|
---|
97 | done
|
---|
98 |
|
---|