]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/scripts/crontab.sh
version 0.7.1
[helm.git] / helm / matita / scripts / crontab.sh
index 926a9750c8ff510a9e5dc61b471b608ea476ffc6..e3f8243e519295423a5c2c0e6efaa7d5cb48ef4b 100644 (file)
@@ -1,3 +1,4 @@
+#!/bin/bash
 MARK=`date +%Y%m%d`
 LASTMARK=`date -d yesterday +%Y%m%d`
 TMPDIRNAME=.__${MARK}_crontab
@@ -7,18 +8,24 @@ OLD=$PWD
 rm -rf $TMPDIRNAME 
 mkdir $TMPDIRNAME
 cd $TMPDIRNAME
-#cvs -d $CVSROOT co helm/matita/scripts 1>/dev/null 2>/dev/null
-#helm/matita/scripts/profile_cvs.sh 2> LOG
+cvs -d $CVSROOT co helm/matita/scripts 1>/dev/null 2>/dev/null
+helm/matita/scripts/profile_cvs.sh 2> LOG
+
+CUR_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$MARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | awk '{print $2}'`
+OLD_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$LASTMARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | awk '{print $2}'`
+
+if [ -z "$CUR_TIME" -o -z "$OLD_TIME" ]; then
+  echo "No benchamks records for $MARK"
+  exit 1
+fi
 
-CUR_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$MARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | cut -f 2`
-OLD_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$LASTMARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | cut -f 2`
 ((DELTA=$CUR_TIME - $OLD_TIME))
 if [ $DELTA -lt 0 ]; then
-  ((DELTA=$DELTA * -1))
+  PERC=0
+else
+  ((PERC=100 * $DELTA))
+  ((PERC=$PERC / $OLD_TIME))
 fi
-((PERC=100 * $DELTA))
-((PERC=$PERC / $OLD_TIME))
-
 if [ $PERC -ge 5 ]; then
   cat <<EOT
   REPORT FOR `date`