source: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager@ 7924

Last change on this file since 7924 was 7924, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.9 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 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
32source `dirname $0`/sourcefile
33user=`whoami`
34
35set -C
36
37makedir $listpath >> $jmscriptlog 2>&1
38makedir $lockpath >> $jmscriptlog 2>&1
39
40notcount=0
41while (( $notcount < 100 ))
42do
43 for (( i=0 ; i < ${#scripts[@]} ; i++ ))
44 do
45 makedir $jmlogpath
46 date >> $jmscriptlog 2>&1
47 echo "sleeping $sleeptime..." >> $jmscriptlog 2>&1
48 sleep $sleeptime
49 dayofweek=`date +%u`
50 hour=`date +%k`
51 source `dirname $0`/sourcefile
52 echo "script: ${scripts[$i]}" >> $jmscriptlog 2>&1
53# echo " day: $dayofweek hour: $hour" >> $jmscriptlog 2>&1
54 queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
55 queued=`setzero $queued`
56 queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
57 queuedscript=`setzero $queuedscript`
58
59 echo "date: "`date`" --- date +%k"`date +%k` >> $jmscriptlog 2>&1
60 echo "--- hour: $hour --- pnototal(hour): ${pnototal[$hour]} --- totalpno: $totalpno ---" >> $jmscriptlog 2>&1
61 totalpno=${pnototal[$hour]}
62 echo "--- hour: $hour --- pnototal(hour): ${pnototal[$hour]} --- totalpno: $totalpno ---" >> $jmscriptlog 2>&1
63 echo "date: "`date`" --- date +%k"`date +%k` >> $jmscriptlog 2>&1
64
65 #choose array according to the day of the week
66 case $dayofweek in
67 0 | 6) pnos=( ${pnoswe[@]} ) ;;
68 *) pnos=( ${pnosweek[@]} ) ;;
69 esac
70 num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
71 pnoscript=${pnos[$num]}
72 echo " found $queued jobs in the queue (incl. running jobs) [allowed $totalpno]" >> $jmscriptlog 2>&1
73 echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs) [allowed $pnoscript]" >> $jmscriptlog 2>&1
74# echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" >> $jmscriptlog 2>&1
75
76 if [ "$queued" -gt "$totalpno" ]
77 then
78 contex >> $jmscriptlog 2>&1
79 else
80 if [ "$queuedscript" -gt "$pnoscript" ]
81 then
82 contex >> $jmscriptlog 2>&1
83 fi
84 fi
85
86 # get todofile
87 lockfile=$lockpath/lock-getting-${scripts[$i]}-list.txt
88 checklock >> $jmscriptlog 2>&1
89 singleprocess="yes"
90 gettodo >> $jmscriptlog 2>&1
91 rm -v $lockfile >> $jmscriptlog 2>&1
92
93 date=`date +%Y/%m/%d`
94 date2=`date +%Y-%m-%d`
95 condordir=$logpath/condor/$date
96 makedir $condordir >> $jmscriptlog 2>&1
97
98 if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date2 -a dir=$condordir $scriptspath/run.condor 2>> $jmerrorlog
99 then
100 date >> $jmerrorlog
101 nail -s 'condor problem' $erradrs < $jmerrorlog
102 echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
103 sleep $errorsleeptime
104 fi
105 echo "" >> $jmscriptlog 2>&1
106 done
107done
108
Note: See TracBrowser for help on using the repository browser.