| 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 resource file for the scripts, in which paths, times and number
|
|---|
| 28 | # of jobs for condor are stored.
|
|---|
| 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 | date #>> $scriptlog 2>&1
|
|---|
| 41 | echo "sleeping $sleeptime..." #>> $scriptlog 2>&1
|
|---|
| 42 | sleep $sleeptime
|
|---|
| 43 | dayofweek=`date +%u`
|
|---|
| 44 | hour=`date +%k`
|
|---|
| 45 | source `dirname $0`/sourcefile
|
|---|
| 46 | echo "script: ${scripts[$i]}" #>> $scriptlog 2>&1
|
|---|
| 47 | # echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&1
|
|---|
| 48 | queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
|
|---|
| 49 | queued=`setzero $queued`
|
|---|
| 50 | queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
|
|---|
| 51 | queuedscript=`setzero $queuedscript`
|
|---|
| 52 |
|
|---|
| 53 | pnototal=${pnototal[$hour]}
|
|---|
| 54 | #choose array according to the day of the week
|
|---|
| 55 | case $dayofweek in
|
|---|
| 56 | 0 | 6) pnos=( ${pnoswe[@]} ) ;;
|
|---|
| 57 | *) pnos=( ${pnosweek[@]} ) ;;
|
|---|
| 58 | esac
|
|---|
| 59 | num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
|
|---|
| 60 | pnoscript=${pnos[$num]}
|
|---|
| 61 | echo " found $queued jobs in the queue (incl. running jobs) [allowed $pnototal]" #>> $scriptlog 2>&1
|
|---|
| 62 | echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs) [allowed $pnoscript]" #>> $scriptlog 2>&1
|
|---|
| 63 | # echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" #>> $scriptlog 2>&1
|
|---|
| 64 |
|
|---|
| 65 | if [ "$queued" -gt "$pnototal" ]
|
|---|
| 66 | then
|
|---|
| 67 | continue
|
|---|
| 68 | else
|
|---|
| 69 | if [ "$queuedscript" -gt "$pnoscript" ]
|
|---|
| 70 | then
|
|---|
| 71 | continue
|
|---|
| 72 | fi
|
|---|
| 73 | fi
|
|---|
| 74 |
|
|---|
| 75 | singleprocess="yes"
|
|---|
| 76 | gettodo
|
|---|
| 77 |
|
|---|
| 78 | y=`date +%Y`
|
|---|
| 79 | m=`date +%m`
|
|---|
| 80 | d=`date +%d`
|
|---|
| 81 | condordir=$logpath/condor/$y/$m/$d
|
|---|
| 82 | makedir $condordir #>> $scriptlog 2>&1
|
|---|
| 83 |
|
|---|
| 84 | # echo " ---> starting ${scripts[$i]} for $process" #>> $scriptlog 2>&1
|
|---|
| 85 |
|
|---|
| 86 | #test
|
|---|
| 87 | contex
|
|---|
| 88 | #test
|
|---|
| 89 | if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a y=$y -a m=$m -a d=$d $scriptspath/run.condor 2>$errorlog
|
|---|
| 90 | then
|
|---|
| 91 | date >> $errorlog
|
|---|
| 92 | nail -s 'condor problem' $erradrs < $errorlog
|
|---|
| 93 | echo "condor is not working -> sleeping $errorsleeptime" >> $scriptlog 2>&1
|
|---|
| 94 | sleep $errorsleeptime
|
|---|
| 95 | fi
|
|---|
| 96 | echo "" >> $scriptlog 2>&1
|
|---|
| 97 | done
|
|---|
| 98 | done
|
|---|
| 99 |
|
|---|