Ignore:
Timestamp:
11/20/11 07:11:38 (13 years ago)
Author:
Daniela Dorner
Message:
included algorithm to make sure that only finished files are zipped
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/ZipRawData.sh

    r12547 r12575  
    77logfile=/home/`whoami`/DataCheck/log/ZipRaw$today.log
    88
     9echo "" >> $logfile 2>&1
     10echo "" >> $logfile 2>&1
     11echo "" >> $logfile 2>&1
    912rawdir=/loc_data/raw/$year/$month
    1013echo `date`": processing files in "$rawdir >> $logfile
     
    2629done
    2730
     31# find all fits-files starting with the oldest file
    2832echo `date`": finding files to be zipped in $rawdir..." >> $logfile
    29 fitsfiles=`find $rawdir -type f -name '*fits' | sort -r`
     33fitsfiles=`find $rawdir -type f -name '*fits'| sort `
    3034
     35# loop to zip files
    3136echo `date`": zipping files in $rawdir..." >> $logfile
    3237for file in $fitsfiles
    3338do
     39   # filename for temporary and final zipfile
    3440   zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
    3541   zipfiletmp=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'`
     
    3945      continue
    4046   fi
     47
     48   # check if files was accessed in the last 30 minutes
     49   isnew=`find $file -amin -30`
     50   if [ "$isnew" != "" ]
     51   then
     52      echo $file" is not older than 30 min => continue" >> $logfile
     53      continue
     54   fi
     55
     56   # check if file is already finished
     57   # original file on daq (if data was taken on daq
     58   origfile=`echo $file | sed -e 's/loc_data/daq/'`
     59   if [ -e $origfile ]
     60   then
     61      # get time of last modification as seconds since Epoch for both files
     62      timeorig=`stat -c %Y $origfile`
     63      timecopy=`stat -c %Y $file`
     64      # compare times
     65      if ! [ $timeorig -eq $timecopy ]
     66      then
     67         # if times are not the same, the file is still open => no zip
     68         echo `date`": file "$file" not yet closed => continue" >> $logfile
     69         continue
     70      fi
     71   else
     72      # if the origfile doesn't exist, the data was probably written not on daq but on data
     73      echo `date`": file "$file" was probably taken on data and not daq " >> $logfile
     74   fi
     75
    4176   echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile
    4277   # zip file to stdout and pipe it to outputfile
    4378   if pigz -1 -c -f $file > $zipfiletmp; 
    4479   then
     80      # if successful, move temporary to final zipfile
    4581      mv -v $zipfiletmp $zipfile >> $logfile
    4682   else
     83      # if not successful, remove temporary zipfile
    4784      rm -v $zipfiletmp >> $logfile
    4885   fi
    4986done
     87
     88
Note: See TracChangeset for help on using the changeset viewer.