#!/usr/bin/ksh # # gmag_cdf_table_update.ksh - Sometimes the CDFs created # don't make it to the database. This script tries # to keep them in sync. # # $1 = year # $2 = month # # Creation Date: # # 22 march 2006 TimQuinn # # ## Set the environment variables # . $HOME/software_dev/config/ground_mag.config . $HOME/software_dev/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 if [[ -z $1 ]] then year=$(date -u '+%Y') month=$(date -u '+%m') else year=$1 month=$(echo $2 | $awk '{printf ("%02s",$1)}') fi 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}') gnet=$(echo $line |awk -F_ '{print $2}') ucsite=$(echo $lcsite | $awk '{printf toupper($1)}') mysql_table_name=${gnet}_${ucsite}_cdffiles rm -f /tmp/gmag_cdf_table_update_${lcsite}.txt grep $filepart ${CONFIGDIR}/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" fileSize=$(ls -l ${L2MAGDIR}/${lcsite}/${year}/$fileName |$awk '{print $5}') #echo $mysql_table_name $dataTime $fileName $processTime $fileSize /home/thmsoc/software_dev/php/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