Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Good link for LIO in Oracle ( Logical IOs) Oracle
  • Jai Shree Ram Oracle
  • Create type and Grant on it. Oracle
  • Kill a session dynanically using execute immediate Oracle
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • Drop tempfiles from database Oracle
  • xargs use Linux/Unix
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • Proc Compilation Oracle
  • tblwopk.sql tablewopk.sql Oracle
  • moving lob object to other tablespace lob_mvmt.sql Oracle
  • fuser to check who is using diretory Linux/Unix
  • DB Console Mainenance. Oracle
  • Proc code Oracle
  • Facts about SCN and Rollback Segment Oracle

remove archfiles only when it is applied to DR rm_archfiles.sh

Posted on 08-Jul-2009 By Admin No Comments on remove archfiles only when it is applied to DR rm_archfiles.sh

echo “script execution starts at `date`”

echo “COMFORT_SPACE=$COMFORT_SPACE”

echo “ARCH_DEST=$ARCH_DEST”

echo “ALERT_LOG=$ALERT_LOG”

ARCH_SPACE=`df -k $ARCH_DEST | tail -1 | awk ‘{print $5}’ | sed ‘s/%//g’`

echo “ARCH_SPACE=$ARCH_SPACE”

STDBY_LAST_RECOVERED_FILE=`grep “Media ” $ALERT_LOG |grep -v grep|grep “arch” | tail -1 | sed -e ‘s#^.*/##g’ `

echo “STDBY_LAST_RECOVERED_FILE=$STDBY_LAST_RECOVERED_FILE”

STDBY_LAST_RECOVERED_NUMBER=`grep “Media ” $ALERT_LOG |grep -v grep|grep “arch” | tail -1 | sed -e ‘s#^.*/##g’ |sed -e ‘s|[^0-9]||g’ `

echo “STDBY_LAST_RECOVERED_NUMBER=$STDBY_LAST_RECOVERED_NUMBER”

STDBY_SAFE_NUMBER=`expr $STDBY_LAST_RECOVERED_NUMBER – 5`

echo “STDBY_SAFE_NUMBER=${STDBY_SAFE_NUMBER}”

TOTAL_FILES_REMOVED=0

echo “The script execution started at `date`”

while [ ${ARCH_SPACE} -ge ${COMFORT_SPACE} ]

do

echo “At the Start-of-loop ARCH_SPACE=${ARCH_SPACE} and COMFORT_SPACE=${COMFORT_SPACE}”

FIRST_FILE=`ls -latr $ARCH_DEST/*.arc|head -1|awk ‘{print $9}’`

ONLY_FILE_NAME=`echo $FIRST_FILE | awk -F”/” ‘{print $NF}’`

SOURCE_FILE_NUMBER=`echo $ONLY_FILE_NAME | awk -F”/” ‘{print $NF}’ | sed -e ‘s|[^0-9]||g’`

echo “FIRST_FILE=${FIRST_FILE} ONLY_FILE_NAME=${ONLY_FILE_NAME} SOURCE_FILE_NUMBER=$SOURCE_FILE_NUMBER”

if [ ${SOURCE_FILE_NUMBER} -ge ${STDBY_SAFE_NUMBER} ]; then

echo “Issue: Cannot remove ${FIRST_FILE} from Standby `hostname`:${ARCH_DEST} as it is not applied to DR. Exiting…”

mailx -s “Blackberry: `hostname` : Archive File-System ${ARCH_DEST} space issue” $NOTIFY_LIST<Server: `hostname`

Issue: Cannot remove ${FIRST_FILE} from Standby `hostname`:${ARCH_DEST} as it is not applied to DR.

COMFORT_SPACE=${COMFORT_SPACE}% CURRENT_SPACE = ${ARCH_SPACE}%

DR: `hostname` Last Recovred File : ${STDBY_LAST_RECOVERED_FILE}

EOF

exit;

else

echo “removing the ${FIRST_FILE}…..”

rm ${FIRST_FILE}

echo “Removed ${FIRST_FILE} at `date`”

sleep 8

TOTAL_FILES_REMOVED=`expr $TOTAL_FILES_REMOVED + 1`

fi

sleep 8

ARCH_SPACE=`df -k $ARCH_DEST | tail -1 | awk ‘{print $5’} | sed ‘s/%//g’`

echo “At the End-of-loop ARCH_SPACE=${ARCH_SPACE} and COMFORT_SPACE=${COMFORT_SPACE}”

done

echo “Total files moved to $ARCH_DEST are ${TOTAL_FILES_REMOVED}”

echo “The script execution ended at `date`”

Linux/Unix, shell

Post navigation

Previous Post: remove archfiles only when it is applied to DR rm_archfiles.sh
Next Post: How to remove blank lines using vi editor command

Related Posts

  • Running some SQL on multiple databases connecting using monitoring userid and password Linux/Unix
  • scripts to take listener.log backup Linux/Unix
  • purge_trc.sh Linux/Unix
  • How to change hostname in Linux Linux/Unix
  • Implementation of key based authentications Linux/Unix
  • Adding a new disk and mount it automatically. on VMWARE LINUX Linux/Unix

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (402)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (18)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (350)
  • SQL Server (6)
  • Uncategorized (5)
  • Videos (0)

Recent Posts

  • SAT Mathematics 10 questions and answer at the end.30-Apr-2026
  • top 10 AI news today30-Apr-2026
  • runon_allpdbs_show_conname.sh23-Apr-2026
  • runon_allcdbs_find_pdbs.sql23-Apr-2026
  • Running PDB on single node in RAC09-Apr-2026
  • find_arc.sql09-Apr-2026
  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026
  • Creating a Container Database using dbaascli08-Apr-2026

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • oracle 11g RAC on vmware Oracle
  • Adding Datafile on Primary Server and Impact on Standby Server Oracle
  • Nice Article about semaphores and init.ora Processes parameter relations Linux/Unix
  • Sending email with file attachment. Linux/Unix
  • Gather Stats manually using DBMS_STATS after disabling DBMS_SCHEDULER jobs as previous entry Oracle
  • This is from Temi Oracle
  • DBMS_SQL for alter session. Oracle
  • chk_space_SID.ksh Linux/Unix

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme