Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Nice Article about semaphores and init.ora Processes parameter relations Linux/Unix
  • Find Stale DR Physical Standby Oracle
  • How to collect CPU usage on Linux using Shell script Linux/Unix
  • GSQ.sql Oracle
  • find_string_in_database.sql Oracle
  • Multiple listeners Oracle
  • Privileges Required to Create Procedures and Functions that uses objects from other schema. Oracle
  • segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used) Oracle
  • Default User Profile Oracle
  • Good Doc 28-JUN-2006 Oracle
  • Rollback force for distributed transactions Oracle
  • To Find Orphan OS processes. Linux/Unix
  • create PLAN_TABLE command. Oracle
  • find_err.sql for finding errors from dba_errors. Oracle
  • Giving Grant on v$DATABASE Oracle

move_arch_files.ksh /* Good One */

Posted on 02-Aug-2005 By Admin No Comments on move_arch_files.ksh /* Good One */

#!/bin/ksh

a=`ps -ef|grep “move_arch_files.ksh”|grep -v grep|wc -l`

if [ $a -gt 2 ]

then

echo “Exiting because of more than 1 Moving archive log script is running ”

exit

fi

#

## Setting Environment information and variables

#

NODENAME=`hostname`

## change start

ORACLE_SID=UAS

LOG_FILE=/oracle/scripts/log/MOVE_UAS01.log

ARCHMOUNTPOINT=/UASARCH

DESTFOLDER=/uocdb7/archlog/UAS

### change end

COMFORT_SPACE=75

NO_FILES_MOVED=0

NOTIFY_LIST=’dbaoracle@1800flowers.com’

cp /dev/null $LOG_FILE

## change start

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

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

##change end

echo “The script execution started at `date`” >> $LOG_FILE

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

do

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

# cp -p $FIRST_FILE /blprddb14/archlog/BLINK

cp -p $FIRST_FILE $DESTFOLDER

CURR_FILE_SZ=`ls -latr $FIRST_FILE|awk ‘{print $5}’`

CURR_FL_NAME=`echo $FIRST_FILE |cut -f3 -d’/’`

# COPIED_FILE_SZ=`ls -latr /blprddb14/archlog/BLINK/$CURR_FL_NAME |awk ‘{print $5}’`

COPIED_FILE_SZ=`ls -latr $DESTFOLDER/$CURR_FL_NAME |awk ‘{print $5}’`

if [ $CURR_FILE_SZ -eq $COPIED_FILE_SZ ]

then

echo “Compressing the $FIRST_FILE” >>$LOG_FILE

compress $DESTFOLDER/$CURR_FL_NAME

echo “compression of $FIRST_FILE is done” >>$LOG_FILE

echo “Removed ” $FIRST_FILE “at “`date` >> $LOG_FILE

rm $FIRST_FILE

fi

NO_FILES_MOVED=`expr $NO_FILES_MOVED + 1`

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

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

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

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

done

if [ $NO_FILES_MOVED -gt 0 ]

then

#echo $NO_FILES_MOVED archive log files were moved from $ARCHMOUNTPOINT to $DESTFOLDER

#echo Currently $ARCHMOUNTPOINT is at $ARCH_SPACE % and $DESTFOLDER is at $ARCHBAK_SPC %

mailx -s ” File Moved Alert from $NODENAME, $ORACLE_SID Database” $NOTIFY_LIST< $NO_FILES_MOVED archive log files were moved from $ARCHMOUNTPOINT to $DESTFOLDER

Currently $ARCHMOUNTPOINT is at $ARCH_SPACE % and $DESTFOLDER is at $ARCHBAK_SPC %

EOF

fi

Linux/Unix, shell

Post navigation

Previous Post: move_arch_files.ksh
Next Post: crontab syntax

Related Posts

  • How to collect CPU usage on Linux using Shell script Linux/Unix
  • Deleting first line and lastline of a file using sed Linux/Unix
  • To see only files and/or folders using LS command Linux/Unix
  • Session_info.ksh Linux/Unix
  • For Search and replace unix command. Linux/Unix
  • telnet listening 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)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • How to choose Driver table in SQL statement Oracle
  • ORA-1841 Error Connecting to Upgraded Database After Set PASSWORD_LIFE_TIME Oracle
  • alter database backup controlfile to trace Oracle
  • Btee and Bitmap Plans in Oracle 9i and higher Oracle
  • Implementing Listener Security Oracle
  • Composite Index creation tip from Vivek Oracle
  • setting prompt display with .profile Linux/Unix
  • crtgr.sql /* For creating trigger from data dictionary */ Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme