Index: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7946)
+++ trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 7959)
@@ -29,5 +29,4 @@
 #
 
-
 source `dirname $0`/sourcefile
 printprocesslog "INFO starting $0"
@@ -54,13 +53,30 @@
       dayofweek=`date +%u`
       hour=`date +%k`
+
       source `dirname $0`/sourcefile
       echo "script: ${scripts[$i]}" >> $jmscriptlog 2>&1
 #      echo " day: $dayofweek hour: $hour" >> $jmscriptlog 2>&1
-      queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user`
-      queued=`setzero $queued`
+
+      queued=`/usr/local/bin/condor_q -global -format "%s\n" Owner | grep -c $user` && ! [ $queued -eq 0 ]
+      if [ "$queued" = "" ]
+      then 
+         printprocesslog "WARN condor_q failed"
+         echo `date`"ERROR condor_q failed" >> $jmerrorlog
+         cont >> $jmscriptlog 2>&1
+      fi
       queuedscript=`/usr/local/bin/condor_q -global | grep $user | grep -c ${scripts[$i]}`
-      queuedscript=`setzero $queuedscript`
+      if [ "$queuedscript" = "" ]
+      then 
+         printprocesslog "WARN condor_q failed"
+         echo `date`"ERROR condor_q failed" >> $jmerrorlog
+         cont >> $jmscriptlog 2>&1
+      fi
       runningscript=`/usr/local/bin/condor_q -global | grep $user | grep ' R ' | grep -c ${scripts[$i]}`
-      runningscript=`setzero $runningscript`
+      if [ "$runningscript" = "" ]
+      then 
+         printprocesslog "WARN condor_q failed"
+         echo `date`"ERROR condor_q failed" >> $jmerrorlog
+         cont >> $jmscriptlog 2>&1
+      fi
       stillinqueue=`echo $queuedscript - $runningscript | bc `
 
@@ -85,9 +101,8 @@
       then
          cont >> $jmscriptlog 2>&1
-      else
-         if [ "$queuedscript" -gt "$pnoscript" ]
-         then
-            cont >> $jmscriptlog 2>&1
-         fi
+      fi
+      if [ "$queuedscript" -gt "$pnoscript" ]
+      then
+         cont >> $jmscriptlog 2>&1
       fi
 
@@ -111,8 +126,7 @@
       if ! /usr/local/bin/condor_submit -a path=$scriptspath -a prog=${scripts[$i]} -a date=$date -a dir=$runlogpath $scriptspath/run.condor 2>> $jmerrorlog
       then 
-         date >> $jmerrorlog
-         nail -s 'condor problem'  $erradrs < $jmerrorlog
+         echo `date`"ERROR condor_submit failed" >> $jmerrorlog
          echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
-         printprocesslog "ERROR submitting ${scripts[$i]} to condor failed"
+         printprocesslog "WARN submitting ${scripts[$i]} to condor failed"
          sleep $errorsleeptime
       fi
