diff --git a/check_cronstatus b/check_cronstatus
index 88b51c71c1d4aaea23030f11caa1e50e44edbaed..e2f579f6fde48208e5286a364ff47efeef246600 100755
--- a/check_cronstatus
+++ b/check_cronstatus
@@ -21,6 +21,7 @@
 # 2019-04-30  v1.2  ah,ds  show scriptlabel of failed jobs in 1st line
 # 2020-02-28  v1.3  ah,ds  ouput with separated error jobs and OK jobs
 # 2020-03-05  v1.4  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
+# 2022-02-28  v1.5  <axel.hahn@iml.unibe.ch> fix output of error counter
 # ======================================================================
 
 
@@ -143,7 +144,7 @@ do
                 if [ $iErr -gt 0 ]; then
                         echo "${sPre}CHECK FAILED"
                         iErrJobs=$iErrJobs+1
-                        echo $iErrJobs > $errfile
+                        echo "$logfile" > $errfile
                         getLogValue SCRIPTLABEL >> $failfile
                 fi
         )>>$sTmpOutfile
@@ -156,7 +157,7 @@ done
 # ----------------------------------------------------------------------
 
 if [ -f $errfile ]; then
-  iErrJobs=`cat $errfile`
+  iErrJobs=$(wc -l $errfile)
   echo "ERROR: $iErrJobs of $iJobs jobs [`cat $failfile | sed ':a;N;$!ba;s/\n/, /g'`] have a problem"
   echo
   echo "********** Jobs with problems:"