Changeset 17590 for trunk/DataCheck/Transfer
- Timestamp:
- 03/02/14 00:35:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Transfer/ZipRawData.sh
r17157 r17590 27 27 fi 28 28 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 31 32 33 # files younger than $delaytime are not processed 32 34 delaytime=5 33 35 … … 47 49 continue 48 50 fi 49 zipdir=/loc_data/zipraw/$date50 if ! [ -d $zipdir ]51 then52 # create output directory for zip53 makedir $zipdir >> $logfile 2>&154 fi55 51 56 52 # find all fits-files starting with the oldest file 57 53 echo `date`": finding files to be zipped in $rawdir..." >> $logfile 2>&1 58 54 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 ` 60 56 61 57 if [ ${#fitsfiles[@]} -eq 0 ] … … 66 62 fi 67 63 64 zipdir=/loc_data/zipraw/$date 65 # create output directory for zip 66 makedir $zipdir >> $logfile 2>&1 67 68 68 # loop to zip files 69 69 echo `date`": zipping files in $rawdir..." >> $logfile 2>&1 … … 71 71 for file in $fitsfiles 72 72 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 ] 78 76 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 80 80 fi 81 81 82 82 # check if raw file was accessed in the last $delaytime minutes 83 83 isnew=`find $file -amin -$delaytime` … … 89 89 fi 90 90 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 113 96 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 125 105 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 142 130 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 ] 152 139 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 155 165 finish 156 166 fi
Note:
See TracChangeset
for help on using the changeset viewer.