#!/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<
Currently $ARCHMOUNTPOINT is at $ARCH_SPACE % and $DESTFOLDER is at $ARCHBAK_SPC %
EOF
fi