#!/usr/bin/ksh #MODIFIED FROM: # gmag_ascii_table_update.ksh - Sometimes the ascii files created # don't make it to the database. This script tries # to keep them in sync. # # $1 = year # $2 = month # $3 = site (lphilpott MY ADDITION) # $4 = gnet (epo, gbo, ath) # Creation Date: # # 22 march 2006 TimQuinn # # ## Set the environment variables # if [[ -z $THMSOC ]] then THMSOC=/disks/socware/thmsoc_dp_current export THMSOC fi . $THMSOC/src/config/ground_mag.config . $THMSOC/src/config/soc_it_to_me.config ## Check for lock file # if [[ -a /var/tmp/gmag_cdf_table_update_lock ]] ; then exit 0 fi echo $$ > /var/tmp/gmag_cdf_table_update_lock ## Determine which awk to use # if [[ $os = "SunOS" ]] then awk=nawk else awk=awk fi year=$1 month=$(echo $2 | $awk '{printf ("%02s",$1)}') filepart=${year}${month} processTime=$(date -u '+%Y-%m-%d %T') #processCode="HardDrive" #for line in $(cat ${CONFIGDIR}/lc_site_list_appended.txt) #do # lcsite=$(echo $line |awk -F_ '{print $1}') lcsite=$3 #gnet=$(echo $line |awk -F_ '{print $2}') gnet=$4 ucsite=$(echo $lcsite | $awk '{printf toupper($1)}') mysql_table_name=${gnet}_${ucsite}_cdffiles rm -f /tmp/gmag_cdf_table_update_${lcsite}.txt grep $filepart ${FILELISTS}/gmag_cdf_list_${lcsite}.txt > /tmp/gmag_cdf_table_update_${lcsite}.txt while read filenamepart do fileName=thg_l2_mag_${lcsite}_${filenamepart}_v01.cdf year=$(echo $filenamepart |$awk '{print substr($1,1,4)}') month=$(echo $filenamepart |$awk '{print substr($1,5,2)}') day=$(echo $filenamepart |$awk '{print substr($1,7,2)}') dataTime="${year}-${month}-${day} 00:00:00" #print $dataTime fileSize=$(ls -l ${L2MAGDIR}/${lcsite}/${year}/$fileName |$awk '{print $5}') #print $fileSize gmag_cdf_table_update.php $mysql_table_name \ $dataTime $fileName $processTime $fileSize done < /tmp/gmag_cdf_table_update_${lcsite}.txt rm -f /tmp/gmag_cdf_table_update_${lcsite}.txt #done rm -f /var/tmp/gmag_cdf_table_update_lock exit 0