Changeset 7908 for trunk/MagicSoft/Mars/datacenter/scripts
- Timestamp:
- 08/22/06 13:05:14 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/datacenter/scripts
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
r7906 r7908 30 30 31 31 32 #source `dirname $0`/sourcefile (is done in jobsourcefile) 33 32 source `dirname $0`/sourcefile 34 33 user=`whoami` 35 sourcefile=/home/$user/Mars.cvs/datacenter/scripts/jobsourcefile36 source $sourcefile37 34 38 35 notcount=0 … … 46 43 dayofweek=`date +%u` 47 44 hour=`date +%k` 48 source $sourcefile45 source `dirname $0`/sourcefile 49 46 echo "script: ${scripts[$i]}" #>> $scriptlog 2>&1 50 echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&147 # echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&1 51 48 queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user` 52 49 queued=`setzero $queued` 53 echo " found $queued jobs in the queue (incl. running jobs)" #>> $scriptlog 2>&154 50 queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}` 55 51 queuedscript=`setzero $queuedscript` 56 echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs)" #>> $scriptlog 2>&157 52 58 53 pnototal=${pnototal[$hour]} … … 64 59 num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc ` 65 60 pnoscript=${pnos[$num]} 66 echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" #>> $scriptlog 2>&1 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 67 64 68 echo " queued: $queued - pnototal: $pnototal" #>> $scriptlog 2>&169 65 if [ "$queued" -gt "$pnototal" ] 70 66 then 71 67 continue 72 68 else 73 echo " queued ${scripts[$i]}: $queuedscript - pno: $pnoscript" #>> $scriptlog 2>&174 69 if [ "$queuedscript" -gt "$pnoscript" ] 75 70 then … … 77 72 fi 78 73 fi 79 80 echo " gettodo..."81 echo "getting db..."82 db=`grep Database $mars/sql.rc | grep -v '#' | sed -e 's/Database: //' -e 's/ //g'`83 col=${scriptscolname[$i]}84 table=`grep "$col:" $steps | sed -e "s/[.]$col://" -e 's/#//' -e 's/ //g'`85 coltab=`grep "$col:" $steps | sed -e 's/://' -e 's/#//' -e 's/ //g'`86 needs=`grep "$coltab[.]Needs:" $steps | sed -e "s/$coltab[.]Needs://"`87 influences=`grep "$coltab[.]Influences:" $steps | sed -e "s/$coltab[.]Influences://"`88 primary=fSequenceFirst89 echo "db: $db - col $col - table $table - coltab $coltab"90 echo "needs: $needs"91 echo "influences: $influences"92 query="select $primary from $table where "93 for need in $needs94 do95 query=$query" not isnull($need) and"96 done97 for influence in $influences98 do99 query=$query" isnull($influence) and"100 done101 query=$query" isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) order by $primary desc limit 0, 1 "102 echo "QUERY: "$query103 echo ""104 echo " gettodofiles -> pno"105 74 106 if [ "$pno" == "0" ] 107 then 108 echo " pno = $pno -> continue" #>> $scriptlog 2>&1 109 echo "" #>> $scriptlog 2>&1 110 continue 111 fi 75 singleprocess="yes" 76 gettodo 112 77 113 78 y=`date +%Y` … … 115 80 d=`date +%d` 116 81 condordir=$logpath/condor/$y/$m/$d 117 makedir 82 makedir $condordir #>> $scriptlog 2>&1 118 83 119 echo " ---> starting $pno ${scripts[$i]}..." #>> $scriptlog 2>&184 # echo " ---> starting ${scripts[$i]} for $process" #>> $scriptlog 2>&1 120 85 121 86 #test 122 echo "" 123 continue 87 contex 124 88 #test 125 89 if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a y=$y -a m=$m -a d=$d $scriptspath/run.condor 2>$errorlog -
trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
r7907 r7908 236 236 } 237 237 238 239 238 function getdbsetup() 239 { 240 db=`grep Database $mars/sql.rc | grep -v '#' | sed -e 's/Database: //' -e 's/ //g'` 241 pw=`grep Password $mars/sql.rc | grep -v '#' | sed -e 's/Password: //' -e 's/ //g'` 242 us=`grep User $mars/sql.rc | grep -v '#' | sed -e 's/User: //' -e 's/ //g'` 243 # echo "setup: " 244 # echo " db: "$db 245 # echo " pw: "$pw 246 # echo " us: "$us 247 } 248 249 function getstepinfo() 250 { 251 if [ "$singleprocess" = "yes" ] 252 then 253 column=${scriptscolname[$i]} 254 fi 255 table=`grep "$column:" $steps | sed -e "s/[.]$column://" -e 's/#//' -e 's/ //g'` 256 coltab=`grep "$column:" $steps | sed -e 's/://' -e 's/#//' -e 's/ //g'` 257 needs=`grep "$coltab[.]Needs:" $steps | sed -e "s/$coltab[.]Needs://"` 258 influences=`grep "$coltab[.]Influences:" $steps | sed -e "s/$coltab[.]Influences://"` 259 primary=`grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"` 260 # echo " column $column - table $table - coltab $coltab" 261 # echo " needs: $needs" 262 # echo " influences: $influences" 263 # echo " primary: $primary" 264 } 265 266 function contex() 267 { 268 echo "" 269 if [ "$singleprocess" = "yes" ] 270 then 271 continue 272 else 273 exit 274 fi 275 } 276 277 function gettodo() 278 { 279 echo "getting todo..." 280 getdbsetup 281 getstepinfo 282 # get query 283 query=" select $primary from $table where " 284 if ! echo $needs | grep '#' > /dev/null 285 then 286 for need in $needs 287 do 288 query=$query" not isnull($need) and" 289 done 290 fi 291 if ! echo $influences | grep '#' > /dev/null 292 then 293 for influence in $influences 294 do 295 query=$query" isnull($influence) and" 296 done 297 fi 298 query=$query" isnull(fStartTime) and isnull(fFailedTime) and isnull(fFailedCode) and isnull(fFailedCodeAdd) and isnull(fReturnCode) order by $primary desc " 299 if [ "$singleprocess" = "yes" ] 300 then 301 query=$query" limit 0, 1 " 302 fi 303 # echo " QUERY: "$query 304 process=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "` 305 306 if [ "$process" = "" ] 307 then 308 echo " => nothing to do" 309 contex 310 else 311 if [ "$singleprocess" = "yes" ] 312 then 313 listfile=$listpath/ToDo-$table-$column-$process.txt 314 echo " => found $process" 315 else 316 listfile=$listpath/ToDo-$table-$column.txt 317 echo "found processes" 318 fi 319 # echo " list: "$listfile 320 321 if ls $listfile > /dev/null 2>&1 322 then 323 echo "$listfile exists already" 324 contex 325 fi 326 echo $process > $listfile 327 fi 328 }
Note:
See TracChangeset
for help on using the changeset viewer.