| 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 08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | # This a script, which launches other scripts
|
|---|
| 28 | #
|
|---|
| 29 |
|
|---|
| 30 | source `dirname $0`/sourcefile
|
|---|
| 31 | printprocesslog "INFO starting $0 $@"
|
|---|
| 32 |
|
|---|
| 33 | errorlog=$runlogpath/scriptlauncher-error`date +%F`.log
|
|---|
| 34 | scriptlog=$runlogpath/scriptlauncher`date +%F`.log
|
|---|
| 35 |
|
|---|
| 36 | echo `date`": starting $0 $@" >> $scriptlog 2>&1
|
|---|
| 37 |
|
|---|
| 38 | path=`dirname $0`
|
|---|
| 39 | date=`date +%Y-%m-%d`
|
|---|
| 40 |
|
|---|
| 41 | num=$#
|
|---|
| 42 | echo "$num scripts have to be launched" >> $scriptlog 2>&1
|
|---|
| 43 | i=1
|
|---|
| 44 |
|
|---|
| 45 | if echo $@ | grep "allatthesametime" >/dev/null 2>$errorlog
|
|---|
| 46 | then
|
|---|
| 47 | all="yes"
|
|---|
| 48 | else
|
|---|
| 49 | all="no"
|
|---|
| 50 | fi
|
|---|
| 51 |
|
|---|
| 52 | while [ $i -le $num ]
|
|---|
| 53 | do
|
|---|
| 54 | com=( )
|
|---|
| 55 | prog=
|
|---|
| 56 | if [ "$1" = "allatthesametime" ]
|
|---|
| 57 | then
|
|---|
| 58 | shift
|
|---|
| 59 | i=`expr $i + 1`
|
|---|
| 60 | continue
|
|---|
| 61 | fi
|
|---|
| 62 | com=( $1 )
|
|---|
| 63 | prog=${com[0]}
|
|---|
| 64 | if ! ls $path/${com[0]} >/dev/null 2>&1
|
|---|
| 65 | then
|
|---|
| 66 | echo "script $path/$1 does not exist." >> $scriptlog 2>&1
|
|---|
| 67 | shift
|
|---|
| 68 | i=`expr $i + 1`
|
|---|
| 69 | continue
|
|---|
| 70 | fi
|
|---|
| 71 | if [ `echo $1 | wc -w` -gt 1 ]
|
|---|
| 72 | then
|
|---|
| 73 | unset com[0]
|
|---|
| 74 | arguments="${com[@]}"
|
|---|
| 75 | fi
|
|---|
| 76 | echo " launching $1..." >> $scriptlog 2>&1
|
|---|
| 77 | echo "/usr/local/bin/condor_submit -a path=$path -a prog=$prog -a args=\"$arguments\" -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2" >> $scriptlog 2>&1
|
|---|
| 78 | pid=`/usr/local/bin/condor_submit -a path=$path -a prog=$prog -a args="$arguments" -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2`
|
|---|
| 79 | if [ "$pid" = "" ]
|
|---|
| 80 | then
|
|---|
| 81 | echo `date`" WARN condor is not working " >> $errorlog 2>&1
|
|---|
| 82 | printprocesslog "WARN submitting $1 to condor failed"
|
|---|
| 83 | shift
|
|---|
| 84 | i=`expr $i + 1`
|
|---|
| 85 | continue
|
|---|
| 86 | fi
|
|---|
| 87 | if [ "$all" = "no" ]
|
|---|
| 88 | then
|
|---|
| 89 | echo " waiting for $1 to be done..." >> $scriptlog 2>&1
|
|---|
| 90 | /usr/local/bin/condor_wait $runlogpath/condor-$date.log $pid >/dev/null 2>$errorlog
|
|---|
| 91 | fi
|
|---|
| 92 | shift
|
|---|
| 93 | i=`expr $i + 1`
|
|---|
| 94 | done
|
|---|
| 95 | echo `date`": all done/submitted." >> $scriptlog 2>&1
|
|---|
| 96 | echo "" >> $scriptlog 2>&1
|
|---|
| 97 |
|
|---|
| 98 | printprocesslog "INFO finished $0 $@"
|
|---|
| 99 |
|
|---|