Index: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7933)
+++ trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7936)
@@ -36,9 +36,10 @@
 
 echo "" >> $jmscriptlog 2>&1
-echo `date`": starting jobmanager" >> $jmscriptlog 2>&1
+echo "starting jobmanager ("`date`")" >> $jmscriptlog 2>&1
 makedir $jmlogpath
 makedir $listpath >> $jmscriptlog 2>&1
 makedir $lockpath >> $jmscriptlog 2>&1
 
+prev=$max
 notcount=0
 while (( $notcount < 100 ))
@@ -72,7 +73,11 @@
       num=`echo "((( $i + 1 ) * 24 ) + ( $hour + 1 ) ) - 24 - 1 " | bc `
       pnoscript=${pnos[$num]}
+      if [ $prev -eq 0 ]
+      then
+         echo " prev=0 => resetting pnoscript [$pnoscript] to max [$max]" >> $jmscriptlog 2>&1
+         pnoscript=$max
+      fi
       echo " found $queued jobs in the queue (incl. running jobs) [allowed $totalpno]" >> $jmscriptlog 2>&1
-      echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs) [allowed $pnoscript]" >> $jmscriptlog 2>&1
-#      echo "  => num=$num => pnoscript=$pnoscript (i.e. $pnoscript ${scripts[$i]} allowed)" >> $jmscriptlog 2>&1
+      echo " found $queuedscript ${scripts[$i]} in the queue (incl. running jobs [$runningscript]) [allowed $pnoscript] - not running: $stillinqueue" >> $jmscriptlog 2>&1
       
       if [ "$queued" -gt "$totalpno" ]
@@ -87,16 +92,15 @@
 
       # check if there's something to do
-      getstatus
+      getstatus >> $jmscriptlog 2>&1
+      echo " $numproc ${scripts[$i]} still do to" >> $jmscriptlog 2>&1
       if [ "$numproc" = "" ]
       then 
+         prev=0
          cont >> $jmscriptlog 2>&1
       fi
-      if ! [ $numproc -gt 0 ]
-      then
-         cont >> $jmscriptlog 2>&1
-      fi
+      prev=$max
       if [ $numproc -lt $stillinqueue ]
       then 
-         echo "numproc($numproc) -lt stillinqueue($stillinqueue)" >> $jmscriptlog 2>&1
+         echo " numproc($numproc) -lt stillinqueue($stillinqueue)" >> $jmscriptlog 2>&1
          cont >> $jmscriptlog 2>&1
       fi
@@ -107,4 +111,5 @@
       makedir $condordir >> $jmscriptlog 2>&1
       
+      echo " committing 1 ${scripts[$i]} to condor" >> $jmscriptlog 2>&1
       if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date2 -a dir=$condordir $scriptspath/run.condor 2>> $jmerrorlog
       then 
@@ -114,4 +119,5 @@
          sleep $errorsleeptime
       fi
+      date >> $jmscriptlog 2>&1
       echo "" >> $jmscriptlog 2>&1
    done
