12.07.2015 Views

Transfer of Data from Terabyte Disk to BMRC Archives

Transfer of Data from Terabyte Disk to BMRC Archives

Transfer of Data from Terabyte Disk to BMRC Archives

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

141 # and if there were, then re-start the same data file part,142 # otherwise increment the part number an run that:143 #144 errCount=‘grep -c -i error ${LastFtpLog}‘145146 # Get the data file and part numbers <strong>from</strong> the previous run:147 #148 # Example:149 # nxt-run: 20041223,171054: Running part file: data1-p6.txt150 #151 LastRunLine=‘tail -1 nxt-run.log‘152153 # Note, AWK arrays are indexed starting <strong>from</strong> 1:154 #155 LastFileNum=‘echo $LastRunLine | awk ’{156 split($6,ary,"-")157 print substr(ary[1],5)158 }’ -‘159 LastPartNum=‘echo $LastRunLine | awk ’{160 split($6,ary,"-")161 split(ary[2],bry,".")162 print substr(bry[1],2)163 }’ -‘164165 if [ $warnCount -gt 0 ]166 then167 # There were some warnings, so send an email <strong>to</strong> the user:168 #169 LastPartFile="data${LastFileNum}-p${LastPartNum}.txt"170 export LastPartFile171 (172 echo "<strong>Data</strong> <strong>Transfer</strong> Warnings"173 echo "----------------------"174 echo "Please see log file: $LastFtpLog"175 echo176 echo "<strong>Data</strong> List Part File: $LastPartFile"177 echo "produced the following warning messages:"178 echo179 grep -C 3 -i warning $LastFtpLog180 ) | mail -s "<strong>Data</strong> <strong>Transfer</strong> Warnings" $MailTo181 fi182183 if [ $errCount -gt 0 ]184 then185 # There were some errors, but perhaps we have attempted re-running186 # the same data part file several times already (i.e., there may187 # be a non-existent file, such as "*.nc.bad", in the list):188 #189 PrevFtpLog=‘ls -1 ftp-*.log | tail -2 | head -1‘190191 result=‘cmp $PrevFtpLog $LastFtpLog‘192 stsOne=$?193194 if [ $stsOne -eq 0 ]195 then196 # The last two ftp log files are identical,197 # so lets try the one before that, <strong>to</strong>o:198 #199 BeforeFtpLog=‘ls -1 ftp-*.log | tail -3 | head -1‘200201 result=‘cmp $BeforeFtpLog $LastFtpLog‘202 stsTwo=$?203204 if [ $stsTwo -eq 0 ]205 then206 # The last three ftp log files are identical,207 # so assume we have some unresolvable error,208 # and re-set the error count <strong>to</strong> zero209 # so that we can make some progress:210 #211 errCount=0212213 # And send some email <strong>to</strong> alert the user:214 #215 LastPartFile="data${LastFileNum}-p${LastPartNum}.txt"216 export LastPartFile217 (218 echo "<strong>Data</strong> <strong>Transfer</strong> Error Loop"219 echo "------------------------"220 echo "The last three ftp log files are identical,"221 echo "so assume we have some unresolvable error,"222 echo "and re-set the error count <strong>to</strong> zero"223 echo "so that we can make some progress:"224 echo225 echo "Please see FTP log files:"226 echo " $BeforeFtpLog"227 echo " $PrevFtpLog"228 echo " $LastFtpLog"229 echo230 echo "<strong>Data</strong> List Part File: $LastPartFile"231 echo "produced some error messages:"232 echo233 grep -i error $LastFtpLog234 echo235 ) | mail -s "<strong>Data</strong> <strong>Transfer</strong> Error Loop" $MailTo236 fi237 fi238 fi239240 if [ $errCount -gt 0 ]241 then242 # There were some errors, so re-run the same data file part:243 #244 PartFile="data${LastFileNum}-p${LastPartNum}.txt"245 else246 # No errors, that’s good. Run the next part:247 #248 NewPartNum=‘expr $LastPartNum + 1‘249 PartFile="data${LastFileNum}-p${NewPartNum}.txt"250 fi251252 if [ ! -f ${PartFile} ]253 then254 echo "${Prog}: ${StartHms}:" >> $LogFile255 echo " WARNING: ${PartFile}: file does not exist." >> $LogFile256257 # Try the next file number and reset part <strong>to</strong> 1:258 #259 NewFileNum=‘expr ${LastFileNum} + 1‘260 PartFile="data${NewFileNum}-p1.txt"261262 if [ ! -f ${PartFile} ]263 then264 echo "${Prog}: ${StartHms}:" >> $LogFile265 echo " WARNING: ${PartFile}: file does not exist." >> $LogFile266267 # Try the next file number with the same part number,268 # e.g., "data10-p92.txt" followed by "data11-p92.txt":269 #270 PartFile="data${NewFileNum}-p${LastPartNum}.txt"271272 if [ ! -f ${PartFile} ]273 then274 echo "${Prog}: ${StartHms}:" >> $LogFile275 echo " ERROR: ${PartFile}: file does not exist." >> $LogFile276 echo " S<strong>to</strong>pping ’crontab’ entry for $MyUser." >> $LogFile277 crontab -r278 exit 3279 fi280 fi281 fi282283 echo "${Prog}: ${StartHms}:" >> $LogFile284285 if [ $errCount -gt 0 ]286 then287 echo " Re-running part file: ${PartFile}" >> $LogFile288 else289 echo " Running part file: ${PartFile}" >> $LogFile290 fi291292 # Also need <strong>to</strong> record this in the "nxt-run.log" file:293 #294 NxtRunLog="nxt-run.log"295 StartDateTime="${StartYmd}-${StartHms}"296297 # NOTE:298 # Please DO NOT change the format <strong>of</strong> the following line,299 # this script depends on "${PartFile}" being the 6th argument:300 #301 echo "${Prog}: ${StartDateTime}: Running part file: ${PartFile}" >> $NxtRunLog302303 cp $PartFile $RemDFlist304305 NewFtpLogFile="${RunPath}/ftp-${StartDateTime}.log"306307 ## LD_LIBRARY_PATH=/home/strandwg/data/tcl8.5a2/lib308 ## export LD_LIBRARY_PATH309310 ## Tcl85sh=/home/strandwg/data/tcl8.5a2/bin/tclsh8.5311 ## export Tcl85sh312313 # Finally, run the selected part <strong>of</strong> the data file number:314 #315 ## ( umask 002; ${Tcl85sh} ${RunPath}/afm-ftp.tcl 2>&1 ) > $NewFtpLogFile &316 ##317 ( umask 002; tclsh ${RunPath}/afm-ftp.tcl 2>&1 ) > $NewFtpLogFile &318319 exit 0320B.10 Program: ‘gwstats’The ‘gwstats’ script runs a few commands which provide a simple snapshot view <strong>of</strong> the status <strong>of</strong> themultiple-terabyte file transfer process <strong>from</strong> a LaCie <strong>Terabyte</strong> disk on a Linux PC <strong>to</strong> the ‘gwork’ temporarys<strong>to</strong>rage area on host ‘gale’:1 #!/bin/sh2 #3 # Program:4 # gwstats5 #6 # RCS-Strings:7 # $Source: /bm/gkeep/lih/src/sh/RCS/gwstats,v $8 # $Revision: 1.1 $9 #10 # Author:11 # Lawson Hanson, 20050209.12 #13 # Purpose:14 # Run a few commands which provide a simple snapshot view <strong>of</strong>15 # the status <strong>of</strong> the multiple-terabyte file transfer process16 # <strong>from</strong> a LaCIE <strong>Terabyte</strong> disk on a Red Hat Linux PC <strong>to</strong> gwork.17 #18 Prog=‘basename $0 .sh‘1920 MyUser=${USER:-${LOGNAME:-nobody}}2122 case $MyUser in23 afm)24 runDir=/bm/gkeep/afm/bmrc/lacie124

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!