Changeset 7959 for trunk/MagicSoft/Mars/datacenter/scripts
- Timestamp:
- 08/30/06 12:33:16 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/datacenter/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
r7946 r7959 29 29 # 30 30 31 32 31 source `dirname $0`/sourcefile 33 32 printprocesslog "INFO starting $0" … … 54 53 dayofweek=`date +%u` 55 54 hour=`date +%k` 55 56 56 source `dirname $0`/sourcefile 57 57 echo "script: ${scripts[$i]}" >> $jmscriptlog 2>&1 58 58 # echo " day: $dayofweek hour: $hour" >> $jmscriptlog 2>&1 59 queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user` 60 queued=`setzero $queued` 59 60 queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user` && ! [ $queued -eq 0 ] 61 if [ "$queued" = "" ] 62 then 63 printprocesslog "WARN condor_q failed" 64 echo `date`"ERROR condor_q failed" >> $jmerrorlog 65 cont >> $jmscriptlog 2>&1 66 fi 61 67 queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}` 62 queuedscript=`setzero $queuedscript` 68 if [ "$queuedscript" = "" ] 69 then 70 printprocesslog "WARN condor_q failed" 71 echo `date`"ERROR condor_q failed" >> $jmerrorlog 72 cont >> $jmscriptlog 2>&1 73 fi 63 74 runningscript=`/usr/local/bin/condor_q -global | grep $user | grep ' R ' | grep -c ${scripts[$i]}` 64 runningscript=`setzero $runningscript` 75 if [ "$runningscript" = "" ] 76 then 77 printprocesslog "WARN condor_q failed" 78 echo `date`"ERROR condor_q failed" >> $jmerrorlog 79 cont >> $jmscriptlog 2>&1 80 fi 65 81 stillinqueue=`echo $queuedscript - $runningscript | bc ` 66 82 … … 85 101 then 86 102 cont >> $jmscriptlog 2>&1 87 else 88 if [ "$queuedscript" -gt "$pnoscript" ] 89 then 90 cont >> $jmscriptlog 2>&1 91 fi 103 fi 104 if [ "$queuedscript" -gt "$pnoscript" ] 105 then 106 cont >> $jmscriptlog 2>&1 92 107 fi 93 108 … … 111 126 if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date -a dir=$runlogpath $scriptspath/run.condor 2>> $jmerrorlog 112 127 then 113 date >> $jmerrorlog 114 nail -s 'condor problem' $erradrs < $jmerrorlog 128 echo `date`"ERROR condor_submit failed" >> $jmerrorlog 115 129 echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1 116 printprocesslog " ERRORsubmitting ${scripts[$i]} to condor failed"130 printprocesslog "WARN submitting ${scripts[$i]} to condor failed" 117 131 sleep $errorsleeptime 118 132 fi -
trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
r7954 r7959 39 39 webpath=/www/htdocs/datacenter 40 40 41 datetime=`date +%F-%H-%M-%S` 42 43 44 # function to make sure that a directory is made 45 function makedir() 46 { 47 if [ ! -d $@ ] 48 then 49 mkdir -pv $@ 50 if [ ! -d $@ ] 51 then 52 echo "could not make dir "$@ 53 finish 54 fi 55 fi 56 } 57 58 # logging paths for runlogs and processlog 41 59 runlogpath=$logpath/run/`date +%Y/%m/%d` 42 60 processlogpath=$logpath/processlog 43 44 datetime=`date +%F-%H-%M-%S` 45 61 makedir $runlogpath 62 makedir $processlogpath 63 processlog=$processlogpath/process`date +%F`.log 64 65 66 # set checkvalue to ok at the beginning of the scripts 46 67 check="ok" 47 68 … … 73 94 Ffillganymed=21 74 95 75 # 76 # setup for jobmanager 77 # 78 #log files (can't be defined in script itself, as script can run longer 79 #than one day 96 97 # setup for jobmanager: 98 # log files (can't be defined in script itself, as script can run longer 99 # than one day 80 100 jmerrorlog=$runlogpath/jobmanager-error`date +%F`.log 81 101 jmscriptlog=$runlogpath/jobmanager`date +%F`.log … … 90 110 stillinqueue=0 91 111 92 function setzero()93 {94 val=$@95 if [ "$val" == "" ]96 then97 test=`condor_q -global`98 if [ "$test" == "" ]99 then100 echo $max101 else102 echo 0103 fi104 else105 echo $val106 fi107 }108 109 110 112 111 113 # alias 112 114 alias 'intgrep'='grep -E ^\\\(int\\\)[0-9]+$ | sed -e s\/\(int\)\/\/' 113 115 114 # in the following the function , which are needed by several scripts, are116 # in the following the functions, which are needed by several scripts, are 115 117 # defined 116 117 # function to make sure that a directory is made118 function makedir()119 {120 if [ ! -d $@ ]121 then122 mkdir -pv $@123 if [ ! -d $@ ]124 then125 echo "could not make dir "$@126 finish127 fi128 fi129 }130 makedir $runlogpath131 makedir $processlogpath132 processlog=$processlogpath/process`date +%F`.log133 118 134 119 function printprocesslog … … 137 122 echo `date +%F\ %T`" "`whoami`"@"$HOSTNAME" "`basename $0`"["$$"] "$@ >> $processlog 138 123 } 139 124 140 125 # function to exit a script properly 141 126 function finish() … … 143 128 rm -v $todofile 144 129 rm -v $lockfile 145 date 130 date 146 131 printprocesslog "INFO finished $program" 147 132 exit … … 158 143 # function to check if a process is already locked 159 144 function checklock() 160 { 145 { 161 146 date > $lockfile 162 147 checklock0=$? 163 case $checklock0 in 148 case $checklock0 in 164 149 0) echo " checklock0=$checklock0 -> continue " ;; 165 150 1) echo " checklock0=$checklock0 -> file $lockfile exists -> exit" 166 date 151 date 167 152 exit;; 168 153 *) echo " checklock0=$checklock0 -> something went completely wrong" ;; … … 176 161 year=`date +%Y` 177 162 date=NULL 178 163 179 164 getstatuslogpath=$logpath/getstatus/$program/$year 180 165 getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log … … 219 204 function evalstatus() 220 205 { 221 case $@ in 206 case $@ in 222 207 start) echo "setstatus start" 223 208 starttime="Now()" … … 235 220 failedcode=$com 236 221 if ! [ "$comadd" = "" ] 237 then 222 then 238 223 failedcodeadd=$comadd 239 224 fi … … 258 243 259 244 # printstatusvalues 260 # set status 245 # set status 261 246 setstatuslogpath=$logpath/setstatus/$program/$var1 262 247 makedir $setstatuslogpath … … 298 283 { 299 284 echo "getting todolist..." 300 getdbsetup 285 getdbsetup 301 286 getstepinfo 302 287 # get query 303 288 query=" select $primary from $table where " 304 if ! echo $needs | grep '#' > /dev/null 305 then 289 if ! echo $needs | grep '#' > /dev/null 290 then 306 291 for need in $needs 307 292 do … … 322 307 if [ "$process" = "" ] 323 308 then 324 echo " => nothing to do" 325 finish 326 else 309 echo " => nothing to do" 310 finish 311 else 327 312 todofile=$listpath/ToDo-$table-$column.txt 328 313 329 314 if ls $todofile > /dev/null 2>&1 330 315 then … … 343 328 process= 344 329 echo "getting todo..." 345 getdbsetup 330 getdbsetup 346 331 getstepinfo 347 332 # get query 348 333 query=" select $primary from $table where " 349 if ! echo $needs | grep '#' > /dev/null 350 then 334 if ! echo $needs | grep '#' > /dev/null 335 then 351 336 for need in $needs 352 337 do … … 368 353 if [ "$process" = "" ] 369 354 then 370 echo " => nothing to do -> exit" 355 echo " => nothing to do -> exit" 371 356 finish 372 357 fi … … 378 363 numproc= 379 364 # echo "getting status..." 380 getdbsetup 365 getdbsetup 381 366 column=${scriptscolname[$i]} 382 367 getstepinfo 383 368 # get query 384 369 query=" select count(*) from $table where " 385 if ! echo $needs | grep '#' > /dev/null 386 then 370 if ! echo $needs | grep '#' > /dev/null 371 then 387 372 for need in $needs 388 373 do … … 394 379 query=$query" group by $column " 395 380 # echo " QUERY: "$query 381 numproc=0 396 382 if ! numproc=`mysql -s -u $us --password=$pw --host=hercules $db -e " $query "` 397 383 then … … 407 393 resetstatusvalues 408 394 evalstatus $@ 409 getdbsetup 395 getdbsetup 410 396 getstepinfo 411 397 # get query … … 413 399 if [ "$reset" = "no" ] 414 400 then 415 echo "YOU CAN'T RESET $column for $var2!!!" 401 echo "YOU CAN'T RESET $column for $var2!!!" 416 402 printprocesslog "ERROR you can't reset $column for $var2" 417 403 finish 418 404 fi 419 405 query=" update $table set $column=$statustime" 420 if ! echo $influences | grep '#' > /dev/null 421 then 406 if ! echo $influences | grep '#' > /dev/null 407 then 422 408 for influence in $influences 423 do 409 do 424 410 query=$query", $influence=NULL" 425 411 done 426 412 fi 427 413 if ! [ "$starttime" = "noreset" ] 428 then 414 then 429 415 query=$query", fStartTime=$starttime" 430 416 fi … … 433 419 echo " QUERY: "$query 434 420 if ! mysql -s -u $us --password=$pw --host=hercules $db -e " $query " 435 then 421 then 436 422 echo "ERROR could not insert status into db -> exit" 437 423 printprocesslog "ERROR could not set status in db (program: $program, function setstatus)" … … 440 426 441 427 } 428
Note:
See TracChangeset
for help on using the changeset viewer.