Ignore:
Timestamp:
03/02/14 00:35:31 (11 years ago)
Author:
Daniela Dorner
Message:
added copying of already compressed files
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Transfer/ZipRawData.sh

    r17157 r17590  
    2727fi
    2828
    29 # setup to use ftools
    30 source $HEADAS/headas-init.sh
     29# not needed anymore as ftools are not used anymore
     30## setup to use ftools
     31#source $HEADAS/headas-init.sh
    3132
     33# files younger than $delaytime are not processed
    3234delaytime=5
    3335
     
    4749      continue
    4850   fi
    49    zipdir=/loc_data/zipraw/$date
    50    if ! [ -d $zipdir ]
    51    then
    52       # create output directory for zip
    53       makedir $zipdir >> $logfile 2>&1
    54    fi
    5551
    5652   # find all fits-files starting with the oldest file
    5753   echo `date`": finding files to be zipped in $rawdir..." >> $logfile 2>&1
    5854   printprocesslog "INFO finding files to be zipped in "$rawdir"..."
    59    fitsfiles=`find $rawdir -type f -name '*fits'| sort `
     55   fitsfiles=`find $rawdir -type f -regex '.*[.]fits[.]?[g]?[f]?[z]?' | sort `
    6056
    6157   if [ ${#fitsfiles[@]} -eq 0 ]
     
    6662   fi
    6763
     64   zipdir=/loc_data/zipraw/$date
     65   # create output directory for zip
     66   makedir $zipdir >> $logfile 2>&1
     67
    6868   # loop to zip files
    6969   echo `date`": zipping files in $rawdir..." >> $logfile 2>&1
     
    7171   for file in $fitsfiles
    7272   do
    73       # filename for temporary and final zipfile
    74       zipfile=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
    75       zipfiletmp=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'`
    76       # check if zipped file already exists
    77       if [ -e $zipfile ]
     73      # check if more than ~ 10 GB are left on /loc_data
     74      diskusage=( `df -P /loc_data | grep /loc_data ` )
     75      if [ ${diskusage[3]} -lt 10000000 ]
    7876      then
    79          continue
     77         echo "WARN less than 10 GB left on /loc_data on data " >> $logfile 2>&1
     78         printprocesslog "WARN less than 10 GB left on /loc_data on data "
     79         finish
    8080      fi
    81 
     81     
    8282      # check if raw file was accessed in the last $delaytime minutes
    8383      isnew=`find $file -amin -$delaytime`
     
    8989      fi
    9090
    91 # not needed anymore, as only complete files are transferred from newdaq to daq
    92 #      # check if file is already finished
    93 #      # original file on daq (if data was taken on daq
    94 #      origfile=`echo $file | sed -e 's/loc_data/daq/'`
    95 #      if [ -e $origfile ]
    96 #      then
    97 #         # get time of last modification as seconds since Epoch for both files
    98 #         timeorig=`stat -c %Y $origfile`
    99 #         timecopy=`stat -c %Y $file`
    100 #         # compare times
    101 #         if ! [ $timeorig -eq $timecopy ]
    102 #         then
    103 #            # if times are not the same, the file is still open => no zip
    104 #            echo `date`": file "$file" not yet closed => continue" >> $logfile 2>&1
    105 #            printprocesslog "WARN file "$file" not yet closed => continue"
    106 #            continue
    107 #         fi
    108 #      else
    109 #         # if the origfile doesn't exist, the data was probably written not on daq but on data
    110 #         echo `date`": file "$file" was probably taken on data and not daq " >> $logfile 2>&1
    111 #         printprocesslog "WARN file "$file" was probably taken on data and not daq "
    112 #      fi
     91      iszipped=`echo $file | grep -o fz`
     92      if [ "$iszipped" == "fz" ]
     93      then
     94         # treat already compressed files
     95         printprocesslog "DEBUG treat compressed file "$file
    11396
    114 #      # update the raw file with the checksums
    115 #      ftchecksum update=yes $file >> $logfile 2>&1
    116 #      check=$?
    117 #      if [ $check -eq 0 ]
    118 #      then
    119 #         echo `date`": file "$file" was updated with the checksums " >> $logfile 2>&1
    120 #      else
    121 #         echo `date`": problem when updating file "$file" (ftchecksum exited with "$check")" >> $logfile 2>&1
    122 #         echo `date`": problem when updating file "$file" (ftchecksum exited with "$check")"
    123 #         continue
    124 #      fi
     97         # filename for file on data
     98         zipfile=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' `
     99         zipfiletmp=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' -e 's/fits.fz/fits.fz.tmp/'`
     100         # check if file on data already exists
     101         if [ -e $zipfile ]
     102         then
     103            continue
     104         fi
    125105
    126       echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile 2>&1
    127       printprocesslog "INFO zipping "$file" to "$zipfile" ..."
    128       #echo "INFO zipping "$file" to "$zipfile" ..."
    129       # read setup again to allow for updates of variables defining transfer
    130       source `dirname $0`/../Sourcefile.sh
    131       # zip file to stdout and pipe it to outputfile
    132       echo "pv --rate-limit $limitpigz $file | pigz -1 -c -f -p $numprocpigz > $zipfiletmp" >> $logfile 2>&1
    133       pv --rate-limit $limitpigz $file | pigz -1 -c -f -p $numprocpigz > $zipfiletmp
    134       statuspigz=( `echo ${PIPESTATUS[@]}` )
    135       printprocesslog "DEBUG PIPESTATUS:"${statuspigz[@]}
    136       echo " PIPESTATUS:"${statuspigz[@]} >> $logfile 2>&1
    137       if [ ${statuspigz[0]} -eq 0 ] && [ ${statuspigz[1]} -eq 0 ]
    138       then
    139          # if successful, move temporary to final zipfile
    140          printprocesslog "INFO move "$zipfiletmp" to "$zipfile" ..."
    141          mv -v $zipfiletmp $zipfile >> $logfile 2>&1
     106         echo `date`": copying "$file" to "$zipfile" ..." >> $logfile 2>&1
     107         printprocesslog "INFO copying "$file" to "$zipfile" ..."
     108         #echo "INFO zipping "$file" to "$zipfile" ..."
     109         # read setup again to allow for updates of variables defining transfer
     110         source `dirname $0`/../Sourcefile.sh
     111         # zip file to stdout and pipe it to outputfile
     112         echo "pv --rate-limit $limitpigz $file > $zipfiletmp" >> $logfile 2>&1
     113         pv --rate-limit $limitpigz $file > $zipfiletmp
     114         statuspv=$?
     115         printprocesslog "DEBUG pvstatus:"$statuspv
     116         echo " pvstatus:"$statuspv >> $logfile 2>&1
     117         if [ $statuspv -eq 0 ]
     118         then
     119            # if successful, move temporary to final zipfile
     120            printprocesslog "INFO move "$zipfiletmp" to "$zipfile" ..."
     121            mv -v $zipfiletmp $zipfile >> $logfile 2>&1
     122         else
     123            # if not successful, remove temporary zipfile
     124            printprocesslog "WARN pv failed (statuspv:"$statuspv")."
     125            echo "WARN pv failed (PIPESTATUS:"$statuspv")." >> $logfile 2>&1
     126            printprocesslog "INFO remove "$zipfiletmp"..."
     127            rm -v $zipfiletmp >> $logfile 2>&1
     128            finish
     129         fi
    142130      else
    143          # if not successful, remove temporary zipfile
    144          printprocesslog "WARN pigz or pv failed (PIPESTATUS:"${statuspigz[@]}")."
    145          echo "WARN pigz or pv failed (PIPESTATUS:"${statuspigz[@]}")." >> $logfile 2>&1
    146          finish
    147          printprocesslog "INFO remove "$zipfiletmp"..."
    148          rm -v $zipfiletmp >> $logfile 2>&1
    149          diskusage=( `df -P /loc_data | grep /loc_data ` )
    150          # check if more than ~ 10 GB are left on /loc_data
    151          if [ ${diskusage[3]} -lt 10000000 ]
     131         # treat uncompressed files
     132         printprocesslog "DEBUG treat uncompressed file "$file
     133
     134         # filename for temporary and final zipfile
     135         zipfile=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
     136         zipfiletmp=`echo $file | sed -e 's/daq/loc_data/g' -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'`
     137         # check if zipped file already exists
     138         if [ -e $zipfile ]
    152139         then
    153             echo "WARN less than 10 GB left on /loc_data on data " >> $logfile 2>&1
    154             printprocesslog "WARN less than 10 GB left on /loc_data on data "
     140            continue
     141         fi
     142
     143         echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile 2>&1
     144         printprocesslog "INFO zipping "$file" to "$zipfile" ..."
     145         #echo "INFO zipping "$file" to "$zipfile" ..."
     146         # read setup again to allow for updates of variables defining transfer
     147         source `dirname $0`/../Sourcefile.sh
     148         # zip file to stdout and pipe it to outputfile
     149         echo "pv --rate-limit $limitpigz $file | pigz -1 -c -f -p $numprocpigz > $zipfiletmp" >> $logfile 2>&1
     150         pv --rate-limit $limitpigz $file | pigz -1 -c -f -p $numprocpigz > $zipfiletmp
     151         statuspigz=( `echo ${PIPESTATUS[@]}` )
     152         printprocesslog "DEBUG PIPESTATUS:"${statuspigz[@]}
     153         echo " PIPESTATUS:"${statuspigz[@]} >> $logfile 2>&1
     154         if [ ${statuspigz[0]} -eq 0 ] && [ ${statuspigz[1]} -eq 0 ]
     155         then
     156            # if successful, move temporary to final zipfile
     157            printprocesslog "INFO move "$zipfiletmp" to "$zipfile" ..."
     158            mv -v $zipfiletmp $zipfile >> $logfile 2>&1
     159         else
     160            # if not successful, remove temporary zipfile
     161            printprocesslog "WARN pigz or pv failed (PIPESTATUS:"${statuspigz[@]}")."
     162            echo "WARN pigz or pv failed (PIPESTATUS:"${statuspigz[@]}")." >> $logfile 2>&1
     163            printprocesslog "INFO remove "$zipfiletmp"..."
     164            rm -v $zipfiletmp >> $logfile 2>&1
    155165            finish
    156166         fi
Note: See TracChangeset for help on using the changeset viewer.