shell [message #97331] |
Thu, 14 March 2002 19:46 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Rudy
Messages: 12 Registered: March 2002
|
Junior Member |
|
|
Hi, i don't know whether this a correct forum to place a shell script question, but,
iam trying to write a shell script, which will look in the current dir for files ending with timestamps.
and delete them.
ex: rudy_03142002_010233
budy_03122002_110155.
Appreciate any help or script.
|
|
|
Re: shell [message #97333 is a reply to message #97331] |
Fri, 15 March 2002 07:23 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Grant
Messages: 578 Registered: January 2002
|
Senior Member |
|
|
I use this to delete old/expired files:
#!/bin/ksh
#
# Purpose: This script is used to remove export and log files over eight days old.
#
# Grant Howell 19-DEC-00
#
# usage: ./clean_old
#
# Set up environment variables
export EXPDIR=/export/home/oracle/exports/backups/*.dmp.Z;
##export EXPDIR=/oradb/OraBackups/exports/*.dmp.Z;
export LOGDIR=$HOME/old_logs/*.log;
export LOGRMAN=/oradb/d1/rman_scripts/*.log;
export LOGRMAN2=/oradb/kham/rman_scripts/*.log;
export LOGRMAN3=/oradb/d2/rman_scripts/*.log;
export AUD816=/oradb/d1/app/oracle/product/8.1.6/rdbms/audit/*.aud;
export AUD817=/oradb/kham/u1/app/oracle/product/8.1.7/rdbms/audit/*.aud;
export AUD817D2=/oradb/d2/u1/app/oracle/product/8.1.7/rdbms/audit/*.aud;
#
#Remove files more than 8 days old.
if test -a $EXPDIR
then
find $EXPDIR -mtime +8 -exec rm {} ;
fi
if test -a $LOGDIR
then
find $LOGDIR -mtime +8 -exec rm {} ;
fi
if test -a $AUD816
then
find $AUD816 -mtime +4 -exec rm {} ;
fi
if test -a $AUD817
then
find $AUD817 -mtime +4 -exec rm {} ;
fi
if test -a $AUD817D2
then
find $AUD817D2 -mtime +4 -exec rm {} ;
fi
if test -a $LOGRMAN
then
find $LOGRMAN -mtime +2 -exec rm -f {} ;
fi
if test -a $LOGRMAN2
then
find $LOGRMAN2 -mtime +2 -exec rm -f {} ;
fi
if test -a $LOGRMAN3
then
find $LOGRMAN3 -mtime +2 -exec rm -f {} ;
fi
|
|
|