#Manish Jaiswal
#!/bin/sh
cd /export/home/nz
. ~/.bashrc
export PATH=/nz/kit/bin:/nz/kit/sbin:/nz/kit/bin/adm:/bin:/usr/bin:/usr/local/bin:.:/nz/support/bin
### Database List needed to be groom
##Big Databases
DB_LIST_WED_SAT=$(nzsql -l |awk ' NR > 3'|sed '$d' |awk '{ print $1 }'|sed '$d'|egrep -E '(PGCIDW|PGCRDW|PMFIDW|PMACDW)')
##small Databases
DB_LIST_SUN=$(nzsql -l |awk ' NR > 3'|sed '$d' |awk '{ print $1 }'|sed '$d'|egrep -v '(PGCIDW|PGCRDW|PMFIDW|PMACDW)')
##############
DBA_email="EDW_Support@gmail.com"
DAY=`date '+%a'`
LOG_DIR=/export/home/nz/scripts/log
LOG=$LOG_DIR/groom_`hostname`_`date +%y%m%d%H%M%S`.log
###Delete 15 days old log
find $LOG_DIR/*.log -type f -mtime +15 -exec rm -f {} \; 2> /dev/null
##############################
###Main Function
groom_db_fn()
{
### running groom for $DAY listed databses
echo "groom started for `hostname1` " > $LOG
for i in `echo $GROOM_DB_LIST`
do
echo "Starting Groom of Database $i on `date +%y%m%d%H%M%S` " >> $LOG
Table_name=$(nzsql -A -c "select objname as table_name from _v_sys_relation_xdb sys where database='$i';"|awk ' NR > 1 '|sed '$d')
for T in `echo $Table_name`
do
nz_groom ${i} $T -records >> $LOG
if [ $? -eq 0 ];then
echo "Completed: Groom of Table $T Database $i on `date +%y%m%d%H%M%S` " >>$LOG
else
echo "Failed: Groom of Table $T Database $i on " >> $LOG
fi
done
done
echo " Find the Groom Report for Netezza `hostname` server in attachment"| mailx -s " Groom Report for Netezza $DAY `hostname` server on `date +%y%m%d%H%M%S` " -a $LOG "$DBA_email"
}
##############################
###checking the day
if [ $DAY == "Wed" ] || [ $DAY == "Sat" ]; then
GROOM_DB_LIST=$DB_LIST_WED_SAT
echo "second block"
groom_db_fn
echo $DAY
elif [ $DAY == "Sun" ]; then
echo $DAY
GROOM_DB_LIST=$DB_LIST_SUN
groom_db_fn
else
echo "GROOM Dont not run on $DAY" > LOG
exit;
fi
What does the string PGCIDW|PGCRDW|PMFIDW|PMACDW
ReplyDeleterepresent?