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

Last change on this file since 7927 was 7927, checked in by Daniela Dorner, 18 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/2006 <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 runningscript=`/usr/local/bin/condor_q -global | grep $user | grep ' R ' | grep -c ${scripts[$i]}`
59 runningscript=`setzero $runningscript`
60 stillinqueue=`echo $queuedscript - $runningscript | bc `
61
62 totalpno=${pnototal[$hour]}
63
64 #choose array according to the day of the week
65 case $dayofweek in
66 0 | 6) pnos=( ${pnoswe[@]} ) ;;
67 *) pnos=( ${pnosweek[@]} ) ;;
68 esac
69 num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
70 pnoscript=${pnos[$num]}
71 echo " found $queued jobs in the queue (incl. running jobs) [allowed $totalpno]" >> $jmscriptlog 2>&1
72 echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs) [allowed $pnoscript]" >> $jmscriptlog 2>&1
73# echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" >> $jmscriptlog 2>&1
74
75 if [ "$queued" -gt "$totalpno" ]
76 then
77 cont >> $jmscriptlog 2>&1
78 else
79 if [ "$queuedscript" -gt "$pnoscript" ]
80 then
81 cont >> $jmscriptlog 2>&1
82 fi
83 fi
84
85 # check if there's something to do
86 getstatus
87 if [ "$numproc" = "" ]
88 then
89 cont >> $jmscriptlog 2>&1
90 fi
91 if ! [ $numproc -gt 0 ]
92 then
93 cont >> $jmscriptlog 2>&1
94 fi
95 if [ $numproc -lt $stillinqueue ]
96 then
97 echo "numproc($numproc) -lt stillinqueue($stillinqueue)" >> $jmscriptlog 2>&1
98 cont >> $jmscriptlog 2>&1
99 fi
100
101 date=`date +%Y/%m/%d`
102 date2=`date +%Y-%m-%d`
103 condordir=$logpath/condor/$date
104 makedir $condordir >> $jmscriptlog 2>&1
105
106 if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date2 -a dir=$condordir $scriptspath/run.condor 2>> $jmerrorlog
107 then
108 date >> $jmerrorlog
109 nail -s 'condor problem' $erradrs < $jmerrorlog
110 echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
111 sleep $errorsleeptime
112 fi
113 echo "" >> $jmscriptlog 2>&1
114 done
115done
116
Note: See TracBrowser for help on using the repository browser.