Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Delete old Archive log Unix script

Re: Delete old Archive log Unix script

From: <Franck_Vasseur_at_ingerrand.com>
Date: Thu, 1 Jun 2000 16:46:07 +0200
Message-Id: <10515.107396@fatcity.com>


I'm not unix specialist but here is a script used last year.

HTH Franck



# If the file system is full and cause oracle to stop, you may want
# to replace 92 by a lower number or increase the number of run or
# do both of them
# This command file check the size of the /u01 file system.
# This should be rewriten when time allowing. We can do way better
# and simpler.
# There are two routines in the script the normal routine which check
# the day and delete the oldest archive " on Monday arch. oldest than 4 days
# on Sunday arch. oldest than 3 days and on any other day of the week arch.
# oldest than 2 days". If the file system is too full and there are no files
# older than the number of day above, a subroutine will start. This subroutine
# delete the files until the file system goes below 92% and then exit.
# You can check the actity of the subroutine in /ops/emergency.log
############################################################################
  df > $COM/filelis.list
   cat $COM/filelis.list | grep u01 > $COM/list     rm $COM/filelis.list
     COUNT=`cut -c37-39 $COM/list`
      rm $COM/list

#
#

 if [ "$COUNT" -gt 92 ]
  then
   echo " file system getting full "
     cd /u01/PROD_ARCH
       date > $COM/datearch.lis
        DAY=`cut -c1-3 $COM/datearch.lis`
         rm $COM/datearch.lis

#
#

   if [ "$DAY" = "Mon" ]; then

      echo " today is monday "
       find /u01/PROD_ARCH -ctime +4 -type f -print > $COM/delarch.lis
         cut -c16-31 $COM/delarch.lis > $COM/cutlis
          cd /u01/PROD_ARCH

#
while true do df > $COM/filelis.list cat $COM/filelis.list | grep u01 > $COM/list rm $COM/filelis.list COUNT=`cut -c37-39 $COM/list` rm $COM/list if [ "$COUNT" -gt 92 ] then EMPTY=`cat $COM/delarch.lis` if [ "$EMPTY" = "" ] then date >> /ops/log/emergency.log ls | head -n3 >> /ops/log/emergency.log cat /ops/log/emergency.log | xargs -t -I {} rm {} sleep 10 fi else break fi done
#
cat $COM/cutlis | xargs -t -I {} rm {} echo " deletion is done let's wait 15 minutes " echo " `date` " rm $COM/delarch.lis rm $COM/cutlis exit

   fi
#
#
#

   if [ "$DAY" = "Sun" ]; then

      echo ' Today is sunday'
       find /u01/PROD_ARCH -ctime +3 -type f -print > $COM/delarch.lis
         cut -c16-31 $COM/delarch.lis > $COM/cutlis
          cd /u01/PROD_ARCH
           while true
            do
             df > $COM/filelis.list
              cat  $COM/filelis.list | grep u01 > $COM/list
               rm $COM/filelis.list
                COUNT=`cut -c37-39 $COM/list`
                 rm $COM/list
                 if [ "$COUNT" -gt 92 ]
                  then
                   EMPTY=`cat $COM/delarch.lis`
                if [ "$EMPTY" = "" ]
                 echo $EMPTY
                  then
                   date >> /ops/log/emergency.log
                   ls | head -n3 >> /ops/log/emergency.log
                    cat /ops/log/emergency.log | xargs -t -I {} rm  {}
                     sleep 10
                fi
            else
                      break
                fi
            done
                      cat $COM/cutlis | xargs -t -I {} rm {}
                       echo " deletion is done let's wait 15 minutes"
                        echo " `date`"
                         rm $COM/delarch.lis
                          rm $COM/cutlis
                           exit
   else
       echo " Normal day of the week"
        find /u01/PROD_ARCH -ctime +2.1 -type f -print > $COM/delarch.lis
         cut -c16-31 $COM/delarch.lis > $COM/cutlis
          cd /u01/PROD_ARCH

#
while true do df > $COM/filelis.list cat $COM/filelis.list | grep u01 > $COM/list rm $COM/filelis.list COUNT=`cut -c37-39 $COM/list` rm $COM/list echo $COUNT if [ "$COUNT" -gt 92 ] then EMPTY=`cat $COM/delarch.lis` if [ "$EMPTY" = "" ] then date >> /ops/log/emergency.log ls | head -n3 >> /ops/log/emergency.log cat /ops/log/emergency.log | xargs -t -I {} rm {} sleep 15 fi else break fi done
#
cat $COM/cutlis | xargs -t -I {} rm {} echo " deletion is done let's wait 15 minutes" echo " `date`" rm $COM/delarch.lis rm $COM/cutlis exit

   fi
#
#

else
  echo "file system ok let's wait 15 minutes"    echo " `date`"
fi
exit
|--------+----------------------->
|        |          Michael Ma   |
|        |          <Michael.Ma_at_e|
|        |          xodus.net>   |
|        |                       |
|        |          00-05-31     |
|        |          19:58        |
|        |          Please       |
|        |          respond to   |
|        |          ORACLE-L     |
|        |                       |
|--------+----------------------->
  >----------------------------------------------------------------------------|
  |                                                                            |
  |       To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>  |
  |       cc:     (bcc: Franck Vasseur/im/esa/ingerrand)                       |
  |       Subject:     Delete old Archive log Unix script                      |
  >----------------------------------------------------------------------------|





Dear DBA,

I would appreciate had any Unix script to delete the old archive log files.

Thanks for the advance,

Michael Ma.

--
Author: Michael Ma
  INET: Michael.Ma_at_exodus.net

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
Received on Thu Jun 01 2000 - 09:46:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US