Index: trunk/DataCheck/RsyncAux.sh
===================================================================
--- trunk/DataCheck/RsyncAux.sh	(revision 12577)
+++ trunk/DataCheck/RsyncAux.sh	(revision 12582)
@@ -1,35 +1,44 @@
 #!/bin/bash
-
-date=`date +%Y/%m/%d --date="-1day"`
 
 today=`date +%F`
 logfile=/home/`whoami`/DataCheck/log/RsyncAux$today.log
 
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-# auxiliary data directories on data 
-auxdirdaq=/daq/aux/$date/ # /loc_data from daq via nfs on data
-auxdirdata=/loc_data/aux/$date 
-echo `date`": processing files in "$auxdir >> $logfile 2>&1
+# get last 3 nights
+dates=( `date +%Y/%m/%d` `date +%Y/%m/%d --date="-1day"` `date +%Y/%m/%d --date="-2day"` `date +%Y/%m/%d --date="-3day"` )
 
-# get current hour
-hour=`date +%k`
-# define bwlimit for rsync depending on the time
-if [ $hour -lt 8 ] || [ $hour -gt 18 ]
-then
-   # limit bw for rsync to 20 MB/s during night
-   bwlimit="--bwlimit=20000"
-   echo "rsync data with "$bwlimit >> $logfile 2>&1
-else 
-   # no bw limit during day
-   echo "rsync data without bwlimit" >> $logfile 2>&1
-fi
+# do rsync for rawfiles of these dates
+for date in ${dates[@]}
+do 
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   # auxiliary data directories on data 
+   auxdirdaq=/daq/aux/$date/ # /loc_data from daq via nfs on data
+   if ! [ -d $auxdirdaq ]
+   then 
+      echo `date`": "$auxdirdaq" not found. Data were probably taken on data" >> $logfile 2>&1
+      continue
+   fi
+   auxdirdata=/loc_data/aux/$date 
+   echo `date`": processing files in "$auxdirdaq >> $logfile 2>&1
+   
+   # get current hour
+   hour=`date +%k`
+   # define bwlimit for rsync depending on the time
+   if [ $hour -lt 8 ] || [ $hour -gt 18 ]
+   then
+      # limit bw for rsync to 20 MB/s during night
+      bwlimit="--bwlimit=20000"
+      echo "rsync data with "$bwlimit >> $logfile 2>&1
+   else 
+      # no bw limit during day
+      echo "rsync data without bwlimit" >> $logfile 2>&1
+   fi
+   
+   #rsync from daq to data
+   if ! /usr/bin/rsync -avxHP $bwlimit $auxdirdaq $auxdirdata >> $logfile 2>&1
+   then
+      echo `date`": problem rsyncing auxiliary data from daq to data"
+   fi
+done
 
-#rsync from daq to data
-if ! /usr/bin/rsync -avxHP $bwlimit $auxdirdaq $auxdirdata >> $logfile 2>&1
-then
-   echo `date`": problem rsyncing auxiliary data from daq to data"
-fi
-
-
Index: trunk/DataCheck/RsyncRaw.sh
===================================================================
--- trunk/DataCheck/RsyncRaw.sh	(revision 12577)
+++ trunk/DataCheck/RsyncRaw.sh	(revision 12582)
@@ -1,35 +1,45 @@
 #!/bin/bash
-
-date=`date +%Y/%m/%d --date="-1day"`
 
 today=`date +%F`
 logfile=/home/`whoami`/DataCheck/log/RsyncRaw$today.log
 
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-# raw data directories on data 
-rawdirdaq=/daq/raw/$date/ # /loc_data from daq via nfs on data
-rawdirdata=/loc_data/raw/$date 
-echo `date`": processing files in "$rawdir >> $logfile 2>&1
+# get last 3 nights
+dates=( `date +%Y/%m/%d` `date +%Y/%m/%d --date="-1day"` `date +%Y/%m/%d --date="-2day"` `date +%Y/%m/%d --date="-3day"` )
 
-# get current hour
-hour=`date +%k`
-# define bwlimit for rsync depending on the time
-if [ $hour -lt 8 ] || [ $hour -gt 18 ]
-then
-   # limit bw for rsync to 20 MB/s during night
-   bwlimit="--bwlimit=20000"
-   echo "rsync data with "$bwlimit >> $logfile 2>&1
-else 
-   # no bw limit during day
-   echo "rsync data without bwlimit" >> $logfile 2>&1
-fi
+# do rsync for rawfiles of these dates
+for date in ${dates[@]}
+do 
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   # raw data directories on data
+   rawdirdaq=/daq/raw/$date/ # /loc_data from daq via nfs on data
+   if ! [ -d $rawdirdaq ]
+   then 
+      echo `date`": "$rawdirdaq" not found. Data were probably taken on data" >> $logfile 2>&1
+      continue
+   fi
+   rawdirdata=/loc_data/raw/$date
+   echo `date`": processing files in "$rawdirdaq >> $logfile 2>&1
 
-#rsync from daq to data
-if ! /usr/bin/rsync -avxHP $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1
-then
-   echo `date`": problem rsyncing rawdata from daq to data"
-fi
+   # get current hour
+   hour=`date +%k`
+   # define bwlimit for rsync depending on the time
+   if [ $hour -lt 8 ] || [ $hour -gt 18 ]
+   then
+      # limit bw for rsync to 20 MB/s during night
+      bwlimit="--bwlimit=20000"
+      echo "rsync data with "$bwlimit >> $logfile 2>&1
+   else
+      # no bw limit during day
+      echo "rsync data without bwlimit" >> $logfile 2>&1
+   fi
+
+   #rsync from daq to data
+   if ! /usr/bin/rsync -avxHP $bwlimit $rawdirdaq $rawdirdata >> $logfile 2>&1
+   then
+      echo `date`": problem rsyncing rawdata from daq to data"
+   fi
+done
 
 
Index: trunk/DataCheck/ZipRawData.sh
===================================================================
--- trunk/DataCheck/ZipRawData.sh	(revision 12577)
+++ trunk/DataCheck/ZipRawData.sh	(revision 12582)
@@ -1,87 +1,87 @@
 #!/bin/bash
-
-year=`date +%Y --date="-1day"`
-month=`date +%m --date="-1day"`
 
 today=`date +%F`
 logfile=/home/`whoami`/DataCheck/log/ZipRaw$today.log
 
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-echo "" >> $logfile 2>&1
-rawdir=/loc_data/raw/$year/$month
-echo `date`": processing files in "$rawdir >> $logfile
+# get last 3 nights
+dates=( `date +%Y/%m/%d` `date +%Y/%m/%d --date="-1day"` `date +%Y/%m/%d --date="-2day"` `date +%Y/%m/%d --date="-3day"` )
 
-#find all directories in $rawdir
-dirs=`find $rawdir -type d | sort`
-
-echo `date`": create missing directories in /loc_data/zipraw/$year/$month" >> $logfile
-for dir in $dirs 
+# do rsync for rawfiles of these dates
+for date in ${dates[@]}
 do 
-   zipdir=`echo $dir | sed -e 's/raw/zipraw/'` 
-   # check if output directory for zip already exists
-   if [ -d $zipdir ] 
-   then 
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   echo "" >> $logfile 2>&1
+   rawdir=/loc_data/raw/$date
+   echo `date`": processing files in "$rawdir >> $logfile
+   # check if data are available from that night
+   if ! [ -d $rawdir ]
+   then
+      echo `date`": no data available in "$rawdir >> $logfile
       continue
    fi
-   # create output directory for zip
-   mkdir -pv $zipdir >> $logfile
-done
-
-# find all fits-files starting with the oldest file
-echo `date`": finding files to be zipped in $rawdir..." >> $logfile
-fitsfiles=`find $rawdir -type f -name '*fits'| sort `
-
-# loop to zip files
-echo `date`": zipping files in $rawdir..." >> $logfile
-for file in $fitsfiles 
-do 
-   # filename for temporary and final zipfile
-   zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'` 
-   zipfiletmp=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'` 
-   # check if zipped file already exists
-   if [ -e $zipfile ] 
-   then 
-      continue
+   zipdir=/loc_data/zipraw/$date
+   if ! [ -d $zipdir ]
+   then
+      # create output directory for zip
+      mkdir -pv $zipdir >> $logfile
    fi
 
-   # check if files was accessed in the last 30 minutes
-   isnew=`find $file -amin -30`
-   if [ "$isnew" != "" ]
-   then
-      echo $file" is not older than 30 min => continue" >> $logfile
-      continue
-   fi
+   # find all fits-files starting with the oldest file
+   echo `date`": finding files to be zipped in $rawdir..." >> $logfile
+   fitsfiles=`find $rawdir -type f -name '*fits'| sort `
 
-   # check if file is already finished
-   # original file on daq (if data was taken on daq
-   origfile=`echo $file | sed -e 's/loc_data/daq/'` 
-   if [ -e $origfile ]
-   then
-      # get time of last modification as seconds since Epoch for both files
-      timeorig=`stat -c %Y $origfile`
-      timecopy=`stat -c %Y $file`
-      # compare times
-      if ! [ $timeorig -eq $timecopy ]
+   # loop to zip files
+   echo `date`": zipping files in $rawdir..." >> $logfile
+   for file in $fitsfiles
+   do
+      # filename for temporary and final zipfile
+      zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
+      zipfiletmp=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'`
+      # check if zipped file already exists
+      if [ -e $zipfile ]
       then
-         # if times are not the same, the file is still open => no zip
-         echo `date`": file "$file" not yet closed => continue" >> $logfile
          continue
       fi
-   else
-      # if the origfile doesn't exist, the data was probably written not on daq but on data
-      echo `date`": file "$file" was probably taken on data and not daq " >> $logfile
-   fi
 
-   echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile
-   # zip file to stdout and pipe it to outputfile
-   if pigz -1 -c -f $file > $zipfiletmp;  
-   then
-      # if successful, move temporary to final zipfile
-      mv -v $zipfiletmp $zipfile >> $logfile
-   else
-      # if not successful, remove temporary zipfile
-      rm -v $zipfiletmp >> $logfile
-   fi
+      # check if raw file was accessed in the last 30 minutes
+      isnew=`find $file -amin -30`
+      if [ "$isnew" != "" ]
+      then
+         echo $file" is not older than 30 min => continue" >> $logfile
+         continue
+      fi
+
+      # check if file is already finished
+      # original file on daq (if data was taken on daq
+      origfile=`echo $file | sed -e 's/loc_data/daq/'`
+      if [ -e $origfile ]
+      then
+         # get time of last modification as seconds since Epoch for both files
+         timeorig=`stat -c %Y $origfile`
+         timecopy=`stat -c %Y $file`
+         # compare times
+         if ! [ $timeorig -eq $timecopy ]
+         then
+            # if times are not the same, the file is still open => no zip
+            echo `date`": file "$file" not yet closed => continue" >> $logfile
+            continue
+         fi
+      else
+         # if the origfile doesn't exist, the data was probably written not on daq but on data
+         echo `date`": file "$file" was probably taken on data and not daq " >> $logfile
+      fi
+
+      echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile
+      # zip file to stdout and pipe it to outputfile
+      if pigz -1 -c -f $file > $zipfiletmp;
+      then
+         # if successful, move temporary to final zipfile
+         mv -v $zipfiletmp $zipfile >> $logfile
+      else
+         # if not successful, remove temporary zipfile
+         rm -v $zipfiletmp >> $logfile
+      fi
+   done
 done
 
