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

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