source: trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher@ 9503

Last change on this file since 9503 was 9130, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.8 KB
Line 
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
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0 $@"
32
33errorlog=$runlogpath/scriptlauncher-error`date +%F`.log
34scriptlog=$runlogpath/scriptlauncher`date +%F`.log
35
36echo `date`": starting $0 $@" >> $scriptlog 2>&1
37
38path=`dirname $0`
39date=`date +%Y-%m-%d`
40
41num=$#
42echo "$num scripts have to be launched" >> $scriptlog 2>&1
43i=1
44
45if echo $@ | grep "allatthesametime" >/dev/null 2>$errorlog
46then
47 all="yes"
48else
49 all="no"
50fi
51
52while [ $i -le $num ]
53do
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`
94done
95echo `date`": all done/submitted." >> $scriptlog 2>&1
96echo "" >> $scriptlog 2>&1
97
98printprocesslog "INFO finished $0 $@"
99
Note: See TracBrowser for help on using the repository browser.