Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Unanswered: reorg script error

    Hi Experts,

    i have written a script here ...but its not producing the output neither i am getting any error .


    Please help

    UTLSTARTTIME=`date +%m%d_%H%M%S`
    UTIL_DATE=`date +20%y-%m-%d-%H:%M:%S`

    echo started list the applications before reorg at `date` >> ${LISTAPPLOG}
    db2 list applications for database $DBNAME show detail >> ${LISTAPPLOG}
    echo end list the applications before reorg at `date` >> ${LISTAPPLOG}
    #disabled force applications to avoid job conflicts
    #db2 force applications all

    db2 connect to $DBNAME >$ERRORLOG

    #selective reorg using reorgchk report starts here.

    db2 "call sysproc.reorgchk_tb_stats('T','ALL')" >$REORGCHKRPT
    db2 -x "select table_schema,table_name from session.tb_stats where reorg <> '---'"|egrep -v 'TABLE_NAME|reco|--'|grep UDBADM| awk '{print $1 "." $2}' > tablist2

    cat tablist2| \
    while read tabname
    do
    echo started reorg on $tabname at `date` >> $ERRORLOG
    db2 reorg table $tabname allow no access >> $ERRORLOG
    echo finished reorg on $tabname at `date` >> $ERRORLOG
    done

    cat tablist2| \
    while read tabname
    do
    echo started runstats on $tabname at `date` >> $ERRORLOG
    db2 "RUNSTATS ON TABLE $tabname with distribution and detailed INDEXES ALL allow write access" >> $ERRORLOG
    echo finished runstats on $tabname at `date` >> $ERRORLOG
    done

    UTLENDTIME=`date +%m%d_%H%M%S`
    echo "$UTIL_DATE :: Reorgrunstats on $DBANE was started at $UTLSTARTTIME and ended at $UTLENDTIME" >> ${UTLTIMELOG}
    db2 connect reset
    db2 archive log for database sdmddb >> $ERRORLOG
    cp /db2prdinst/db2inst1/admin/SDMDDB/logs/reorgrunstats.log /db2prdinst/db2inst1/admin/SDMDDB/logs/hist/reorgrunstats.log.$UTLSTARTTIME
    echo ER $DBNAME selective Reorg runstats started at $UTLSTARTTIME and ended at $UTLENDTIME |mailx -s "ER $DBNAME selective Reorg Runstats complete" $mail_address

    #Errors will be filtered and sent to bb_alert via following script.
    . /db2prdinst/db2inst1/admin/SDMDDB/reorgstatusemail1.sh
    #New steps are as follows.
    db2 connect to sdmddb >> $ERRORLOG
    echo flush package command executed here >> $ERRORLOG
    db2 flush package cache dynamic >> $ERRORLOG

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You need to supply your DB2 version and OS. Also supply what the script does.

    You also need to understand that "db2 force applications" is asynchronous. The command will return back immediately, but the applications may take some time to actually be disconnected (this is due to rollbacks).

    Also reorg is also asynchronous. Issuing the command will fire off the reorg, but will return before the reorg actually finishes.

    You need to adjust your script accordingly.

    Andy

  3. #3
    Join Date
    Mar 2011
    Posts
    4
    Thanks for your reply !!

    i am not sure ..if these 2 lines are working fine or not ?

    db2 "call sysproc.reorgchk_tb_stats('T','ALL')" >$REORGCHKRPT
    db2 -x "select table_schema,table_name from session.tb_stats where reorg <> '---'"|egrep -v 'TABLE_NAME|reco|--'|grep EDCNDC | awk '{print $1 "." $2}' > tablist2


    can you please confirm that ?

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Try running them manually to see if they are doing what you want. My Linux/Unix scripting is rudimentary at best.

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •