Ignore:
Timestamp:
08/22/06 13:05:14 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/datacenter/scripts
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/jobmanager

    r7906 r7908  
    3030
    3131
    32 #source `dirname $0`/sourcefile (is done in jobsourcefile)
    33 
     32source `dirname $0`/sourcefile
    3433user=`whoami`
    35 sourcefile=/home/$user/Mars.cvs/datacenter/scripts/jobsourcefile
    36 source $sourcefile
    3734
    3835notcount=0
     
    4643      dayofweek=`date +%u`
    4744      hour=`date +%k`
    48       source $sourcefile
     45      source `dirname $0`/sourcefile
    4946      echo "script: ${scripts[$i]}" #>> $scriptlog 2>&1
    50       echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&1
     47#      echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&1
    5148      queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
    5249      queued=`setzero $queued`
    53       echo " found $queued jobs in the queue (incl. running jobs)" #>> $scriptlog 2>&1
    5450      queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
    5551      queuedscript=`setzero $queuedscript`
    56       echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs)" #>> $scriptlog 2>&1
    5752
    5853      pnototal=${pnototal[$hour]}
     
    6459      num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
    6560      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
    6764     
    68       echo " queued: $queued - pnototal: $pnototal" #>> $scriptlog 2>&1
    6965      if [ "$queued" -gt "$pnototal" ]
    7066      then
    7167         continue
    7268      else
    73          echo " queued ${scripts[$i]}: $queuedscript - pno: $pnoscript" #>> $scriptlog 2>&1
    7469         if [ "$queuedscript" -gt "$pnoscript" ]
    7570         then
     
    7772         fi
    7873      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=fSequenceFirst
    89       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 $needs
    94       do
    95          query=$query" not isnull($need) and"
    96       done
    97       for influence in $influences
    98       do
    99          query=$query" isnull($influence) and"
    100       done
    101       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: "$query
    103       echo ""
    104       echo " gettodofiles -> pno"
    10574
    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
    11277
    11378      y=`date +%Y`
     
    11580      d=`date +%d`
    11681      condordir=$logpath/condor/$y/$m/$d
    117       makedir  $condordir #>> $scriptlog 2>&1
     82      makedir $condordir #>> $scriptlog 2>&1
    11883     
    119       echo "  ---> starting $pno ${scripts[$i]}..." #>> $scriptlog 2>&1
     84#      echo "  ---> starting ${scripts[$i]} for $process" #>> $scriptlog 2>&1
    12085     
    12186      #test
    122       echo ""
    123       continue
     87      contex
    12488      #test
    12589      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  
    236236}
    237237
    238 
    239 
     238function 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
     249function 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
     266function contex()
     267{
     268   echo ""
     269   if [ "$singleprocess" = "yes" ]
     270   then
     271      continue
     272   else
     273      exit
     274   fi
     275}
     276
     277function 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.