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

Last change on this file since 7904 was 7904, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/sh
2#
3
4source /home/operator/condor/jobsourcefile
5
6notcount=0
7while (( $notcount < 100 ))
8do
9 for (( i=0 ; i < ${#scripts[@]} ; i++ ))
10 do
11 date
12 echo "sleeping $sleeptime..."
13 sleep $sleeptime
14 dayofweek=`date +%u`
15 hour=`date +%k`
16 source /home/operator/condor/jobsourcefile
17 echo "script: ${scripts[$i]}"
18 echo " day: $dayofweek hour: $hour"
19# running=`/usr/local/bin/condor_q -global | grep -c ' R '`
20 running=`/usr/local/bin/condor_q -global | grep operator | grep -c ' R '`
21 running=`setzero $running`
22 echo " found $running jobs running"
23# queued=`/usr/local/bin/condor_q -global -format "job\n" ProcId | wc -l`
24 queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c operator`
25 queued=`setzero $queued`
26 echo " found $queued jobs in the queue (incl. running jobs)"
27# runningscript=`/usr/local/bin/condor_q -global | grep ${scripts[$i]} | grep -c ' R '`
28 runningscript=`/usr/local/bin/condor_q -global | grep operator | grep ${scripts[$i]} | grep -c ' R '`
29 runningscript=`setzero $runningscript`
30 echo " found $runningscript ${scripts[$i]} running"
31# queuedscript=`/usr/local/bin/condor_q -global | grep -c ${scripts[$i]}`
32 queuedscript=`/usr/local/bin/condor_q -global | grep operator | grep -c ${scripts[$i]}`
33 queuedscript=`setzero $queuedscript`
34 echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs)"
35
36 #unguenstig, da es ja f versch scripte untersch sein kann
37# if [ "$runningscriptold" == "$runningscript" ]
38# then
39# echo "$runningscriptold = $runningscript"
40# sleeptime=`echo "2 * $sleeptime" | bc`
41# echo "new sleeptime: $sleeptime"
42# fi
43# runningscriptold=$runningscript
44 pnototal=${pnototal[$hour]}
45 echo " pnototal=$pnototal (allowed no of jobs)"
46 if [ "$pnototal" -lt "$running" ]
47 then
48 echo " pnototal=$pnototal < $running (running) => continue"
49 echo ""
50 continue
51 fi
52 #choose array according to the day of the week
53 case $dayofweek in
54 0 | 6) pnos=( ${pnoswe[@]} ) ;;
55 *) pnos=( ${pnosweek[@]} ) ;;
56 esac
57 num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
58 pnoscript=${pnos[$num]}
59 echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)"
60
61 echo " queued: $queued - pnototal: $pnototal"
62 if [ "$queued" -lt "$pnototal" ]
63 then
64# echo "$queued -lt $pnototal"
65# if [ "$queuedscript" -lt "$queued" ]
66# then
67# echo "$queuedscript -lt $queued"
68# queuedscript=$queued
69# fi
70 echo " queued ${scripts[$i]}: $queuedscript - pno: $pnoscript"
71 if [ "$queuedscript" -lt "$pnoscript" ]
72 then
73 pno=`echo " $pnoscript - $queuedscript " | bc`
74 fi
75 fi
76
77 if [ "$pno" == "0" ]
78 then
79 echo " pno = $pno -> continue"
80 echo ""
81 continue
82 fi
83
84 date=`date +\%Y/\%m/\%d`
85 condordir=/magic/datacenter/autologs/condor/$date
86 if [ ! -d $condordir ]
87 then
88 mkdir -pv $condordir
89 if [ ! -d $condordir ]
90 then
91 echo "could not make dir "$condordir
92 exit
93 fi
94 fi
95
96 echo " ---> starting $pno ${scripts[$i]}..."
97 if ! /usr/local/bin/condor_submit -a dir=$scriptsdir -a pno=$pno -a prog=${scripts[$i]} -a date=$date -a hour=`date +\%H` /home/operator/condor/run.condor 2>$errorfile
98 then
99 nail -s 'condor problem' $adrs < $errorfile
100 echo "condor is not working -> exit"
101 exit
102 fi
103 echo ""
104 done
105done
Note: See TracBrowser for help on using the repository browser.