Index: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7924)
+++ trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7927)
@@ -18,5 +18,5 @@
 #
 #
-#   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
+#   Author(s): Daniela Dorner  05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
 #   Copyright: MAGIC Software Development, 2000-2006
@@ -56,10 +56,9 @@
       queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
       queuedscript=`setzero $queuedscript`
+      runningscript=`/usr/local/bin/condor_q -global | grep $user | grep ' R ' | grep -c ${scripts[$i]}`
+      runningscript=`setzero $runningscript`
+      stillinqueue=`echo $queuedscript - $runningscript | bc `
 
-      echo "date: "`date`" --- date +%k"`date +%k` >> $jmscriptlog 2>&1
-      echo "--- hour: $hour --- pnototal(hour): ${pnototal[$hour]} --- totalpno: $totalpno ---" >> $jmscriptlog 2>&1
       totalpno=${pnototal[$hour]}
-      echo "--- hour: $hour --- pnototal(hour): ${pnototal[$hour]} --- totalpno: $totalpno ---" >> $jmscriptlog 2>&1
-      echo "date: "`date`" --- date +%k"`date +%k` >> $jmscriptlog 2>&1
       
       #choose array according to the day of the week
@@ -76,18 +75,27 @@
       if [ "$queued" -gt "$totalpno" ]
       then
-         contex >> $jmscriptlog 2>&1
+         cont >> $jmscriptlog 2>&1
       else
          if [ "$queuedscript" -gt "$pnoscript" ]
          then
-            contex >> $jmscriptlog 2>&1
+            cont >> $jmscriptlog 2>&1
          fi
       fi
 
-      # get todofile
-      lockfile=$lockpath/lock-getting-${scripts[$i]}-list.txt
-      checklock  >> $jmscriptlog 2>&1
-      singleprocess="yes"
-      gettodo  >> $jmscriptlog 2>&1
-      rm -v $lockfile >> $jmscriptlog 2>&1
+      # check if there's something to do
+      getstatus
+      if [ "$numproc" = "" ]
+      then 
+         cont >> $jmscriptlog 2>&1
+      fi
+      if ! [ $numproc -gt 0 ]
+      then
+         cont >> $jmscriptlog 2>&1
+      fi
+      if [ $numproc -lt $stillinqueue ]
+      then 
+         echo "numproc($numproc) -lt stillinqueue($stillinqueue)" >> $jmscriptlog 2>&1
+         cont >> $jmscriptlog 2>&1
+      fi
 
       date=`date +%Y/%m/%d`
