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

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