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

Legend:

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

    r7905 r7906  
    11#!/bin/sh
    22#
     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 resource file for the scripts, in which paths, times and number
     28# of jobs for condor are stored.
     29#
    330
    4 source /home/operator/condor/jobsourcefile
     31
     32#source `dirname $0`/sourcefile (is done in jobsourcefile)
     33
     34user=`whoami`
     35sourcefile=/home/$user/Mars.cvs/datacenter/scripts/jobsourcefile
     36source $sourcefile
    537
    638notcount=0
     
    941   for (( i=0 ; i < ${#scripts[@]} ; i++ ))
    1042   do
    11       date
    12       echo "sleeping $sleeptime..."
     43      date  #>> $scriptlog 2>&1
     44      echo "sleeping $sleeptime..." #>> $scriptlog 2>&1
    1345      sleep $sleeptime
    1446      dayofweek=`date +%u`
    1547      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`
     48      source $sourcefile
     49      echo "script: ${scripts[$i]}" #>> $scriptlog 2>&1
     50      echo " day: $dayofweek hour: $hour" #>> $scriptlog 2>&1
     51      queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
    2552      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]}`
     53      echo " found $queued jobs in the queue (incl. running jobs)" #>> $scriptlog 2>&1
     54      queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
    3355      queuedscript=`setzero $queuedscript`
    34       echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs)"
     56      echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs)" #>> $scriptlog 2>&1
    3557
    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
    4458      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
    5259      #choose array according to the day of the week
    5360      case $dayofweek in
     
    5764      num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
    5865      pnoscript=${pnos[$num]}
    59       echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)"
     66      echo " => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" #>> $scriptlog 2>&1
    6067     
    61       echo " queued: $queued - pnototal: $pnototal"
    62       if [ "$queued" -lt "$pnototal" ]
     68      echo " queued: $queued - pnototal: $pnototal" #>> $scriptlog 2>&1
     69      if [ "$queued" -gt "$pnototal" ]
    6370      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" ]
     71         continue
     72      else
     73         echo " queued ${scripts[$i]}: $queuedscript - pno: $pnoscript" #>> $scriptlog 2>&1
     74         if [ "$queuedscript" -gt "$pnoscript" ]
    7275         then
    73             pno=`echo " $pnoscript - $queuedscript " | bc`
     76            continue
    7477         fi
    7578      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"
    76105
    77106      if [ "$pno" == "0" ]
    78107      then
    79          echo " pno = $pno -> continue"
    80          echo ""
     108         echo " pno = $pno -> continue" #>> $scriptlog 2>&1
     109         echo "" #>> $scriptlog 2>&1
    81110         continue
    82111      fi
    83112
    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
     113      y=`date +%Y`
     114      m=`date +%m`
     115      d=`date +%d`
     116      condordir=$logpath/condor/$y/$m/$d
     117      makedir  $condordir #>> $scriptlog 2>&1
     118     
     119      echo "  ---> starting $pno ${scripts[$i]}..." #>> $scriptlog 2>&1
     120     
     121      #test
     122      echo ""
     123      continue
     124      #test
     125      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
     126      then
     127         date >> $errorlog
     128         nail -s 'condor problem'  $erradrs < $errorlog
     129         echo "condor is not working -> sleeping $errorsleeptime" >> $scriptlog 2>&1
     130         sleep $errorsleeptime
    94131      fi
    95      
    96       echo "  ---> starting $pno ${scripts[$i]}..."
    97       for (( j=1 ; j <= $pno ; j++ ))
    98       do
    99          echo "$i - $pno -> sleeping...."
    100          sleep 2
    101          if ! /usr/local/bin/condor_submit -a dir=$scriptsdir -a prog=${scripts[$i]} -a date=$date -a hour=`date +\%H` /home/operator/condor/run.condor 2>$errorfile
    102          then
    103             nail -s 'condor problem'  $adrs < $errorfile
    104             echo "condor is not working -> exit"
    105             exit
    106          fi
    107       done
    108       echo ""
     132      echo "" >> $scriptlog 2>&1
    109133   done
    110134done
     135
Note: See TracChangeset for help on using the changeset viewer.