|
|
|
|
| Re: Delete files using shell scripts. [message #257563 is a reply to message #257396] |
Wed, 08 August 2007 11:49  |
DreamzZ
Messages: 1666 Registered: May 2007 Location: Dreamzland
|
Senior Member |
|
|
some thing like this.Edit it according your requirments.
#!/bin/ksh -x
. $HOME/.profile_mydb
STATS_LOG_DIR=$STATS_HOME_DIR/log
DATE=`date +%Y%m%d%H%M`
STATS_LOG=$STATS_LOG_DIR/stats_dell_pull.log.$DATE
STATS_SQLPLUS_LOG=$STATS_LOG_DIR/stats.SQLPLUS_dell_pull.log.$DATE
DEL_LOG=/tmp/${ORACLE_SID}_DAILYLOGS_DELL_PULL.del;
DAILYLOGS=/tmp/${ORACLE_SID}_DAILYLOGS_DELL_PULL;
ERROR_FLG='0'
# List the Log Files in the Decending Order of Creation Time
ls -t ${STATS_LOG_DIR} > ${DAILYLOGS}
print "Starting Time : `date` \n" >> $DEL_LOG
count=0
# Starting the Loop for Deletion, Leaving the Latest 40 Arc.Files
unalias rm
for i in `cat ${DAILYLOGS}`
do
count=`expr ${count} + 1`
if (( ${count} > 10 )); then
echo "Deleting ${count}; ${STATS_LOG_DIR}/${i}\n" >> $DEL_LOG
rm ${STATS_LOG_DIR}/${i}
fi
done
|
|
|
|