$ compare_artist_exports.ksh #!/bin/ksh # # Script for generating Daily Table Statistics by Marin Komadina # DATESTRING=`date+%Y%m%d_%H%M` LOGFILE=/backup_data/export/compare_artist_exports_${DATESTRING}.log MAILLIST="arist@global.net" typeset OLDLOG NEWLOG for i in `ls -rt /backup_data/export/exp_artist_*.log | tail -2` do if [ -z $OLDLOG ] ; then OLDLOG=$i else NEWLOG=$i fi done echo "---------------------------------------------------------------------------------------------------" >> ${LOGFILE} echo "Daily Database Grow : \n" >> ${LOGFILE} echo "Old Logfile: $OLDLOG" >> ${LOGFILE} echo "New Logfile: $NEWLOG\n" >> ${LOGFILE} echo "Table Old Records New Records Daily Increase " >> ${LOGFILE} echo "---------------------------------------------------------------------------------------------------" >> ${LOGFILE} # while read line do typeset -LZ10 EXPORTED=`echo $line | awk '{print $3}'` if [ ! -z $EXPORTED ] ; then if [ $EXPORTED = "exporting" ] ; then typeset -L35 TABLENAME=`echo $line | awk '{print $5}'` typeset -i ROWCOUNT1=`echo $line | awk '{print $6}'` if [ $ROWCOUNT1 -gt 0 ]; then typeset -i ROWCOUNT2=`grep -w $TABLENAME $OLDLOG | awk '{print $6}'` typeset -i ROWCOUNT3=`expr $ROWCOUNT1 - $ROWCOUNT2` typeset -L15 C_ROWCOUNT1=$ROWCOUNT1 typeset -L15 C_ROWCOUNT2=$ROWCOUNT2 if [ $ROWCOUNT3 -ne 0 ]; then echo "${TABLENAME}Old: ${C_ROWCOUNT2}New: ${C_ROWCOUNT1}\c" >> ${LOGFILE} echo "Delta: $ROWCOUNT3" >> ${LOGFILE} else echo "${TABLENAME}Old: ${C_ROWCOUNT2}New: ${C_ROWCOUNT1}" >> ${LOGFILE} fi fi fi fi done < $NEWLOG echo "\n---------------------------------------------------------------------------------------------------" >> ${LOGFILE} echo "End of Program!" >> ${LOGFILE} echo "---------------------------------------------------------------------------------------------------\n" >> ${LOGFILE} mailx -s "Daily Database Increase, ${DATESTRING}" $MAILLIST < $LOGFILE exit $? # Now you can call script for deleting old export file # # EOF: #