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

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