a=`ps -ef|grep $SCRIPT_NAME|grep -v grep|wc -l`
if [ $a -gt 2 ]
then
echo “Exiting because of more than 1 Moving archive log script is running ” >>$LOGFILE
exit
fi
cd $DESTFOLDER
b=0
buffersize=85
currentdskspce=`df -k $DESTFOLDER|tail -1 |awk {‘print $5’}| sed ‘s/%//g’`
echo “This $DESTFOLDER files removal script was executed on `date`” >>$LOGFILE
while [ $currentdskspce -ge $buffersize ]
do
b=1
files2remove=`ls -latr * |head -1|awk {‘print $9’}`
echo “the files to be removed are $files2remove” >>$LOGFILE
rm $files2remove
currentdskspce=`df -k $DESTFOLDER|tail -1 |awk {‘print $5’}| sed ‘s/%//g’`
echo “the current space utilization is $currentdskspce” >>$LOGFILE
done
if [ $b -gt 0 ]
then
mailx -s ” File Removed Alert from $NODENAME, $ORACLE_SID Database” $NOTIFY_LIST<
Currently $DESTFOLDER is at $currentdskspce %
EOF
fi