Shell script for purging the 3 days old files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script for purging the 3 days old files
# 1  
Old 08-17-2009
Shell script for purging the 3 days old files

Hi all,

I try to write shell script to the below requirement.

I have Hard coded the oratab location and take the list of databases from oratab and find out archive log locations for each database,
and list more than 3 days old files for each location and purge those.

ORATAB=/var/opt/oracle/oratab
SID_LIST =`cat ORATAB | cut -f1 -d :`
for ORACLE_SID in ${SID_LIST} ; do
export ORACLE_SID=&ORACLE_SID
export ORACLE_HOME=`grep ^${ORACLE_SID}: ${ORATAB} | cut -d: -f2`
$ORACLE_HOME/bin/sqlplus -s /nolog > ${TMPFILE} << EOF
connect / as sysdba;

select value from v$parameter where NAME ='log_archive_dest';
EOF

From the above shell script i am able to find the archive log location and stored in tmpfile.
I want to know how to read that file and purge the 3 days old files from the specified path
Pleae help me to find out the solution

Thaks in advance

Regards,
Makesh boopathi.k.s.
# 2  
Old 08-17-2009
Code:
find ${TMPFILE} -mtime +3 -exec rm -f {} \;

TEST this first to make sure the -mtime +3 is what you really want.
# 3  
Old 08-18-2009
Thanks a lot

Regards,
Makesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for connecting multiple servers and then copying 30 days old files

Shell script for connecting multiple servers and then copying 30 days old files from those server . HI , I have 6 multiple servers pla1,pla2,pla3,pla4,pla5,pla6 1. These six servers have common shared mount point /var/share 2. Running script from /var/share to connect these servers.I... (1 Reply)
Discussion started by: rcroyal88
1 Replies

2. Shell Programming and Scripting

Disc space issues and purging of files

Hi All, I am looking forward to create a unix shell script to purge the files. The requirement is: 1) Do df -k and check the current space occupied for the /a1 folder. 2) If the space consumed is greater than 90 %, delete all the DEF* files from a subfolder /a1/archive. Example: df... (4 Replies)
Discussion started by: shilpa_acc
4 Replies

3. Shell Programming and Scripting

Fine Tune - Huge files/directory - Purging

Hi Expert's, I need your assitance in tunning one script. I have a mount point where almost 4848008 files and 864739 directories are present. The script search for specific pattern files and specfic period then delete them to free up space. The script is designed to run daily and its taking around... (19 Replies)
Discussion started by: senthil.ak
19 Replies

4. Shell Programming and Scripting

how to delete 3 days old files using ftp in a shell script (Solaris OS)

I need help in writng a script to delete last three days files from a remote server using only FTP / SFTP. I was using find command which is not working and i cant use ssh Immediate response is highly appreciated . Thank in advance! ---------- Post updated 12-05-10 at 09:16 PM ----------... (5 Replies)
Discussion started by: Olivia
5 Replies

5. Shell Programming and Scripting

purging of Files

Hello All, I want to delete the files based on the days. like, Files available under directory /abc want to delete if they are older than 15 days. Files available under directory /pqr want to delete if they are 7 days old and some files under directory /xyz should get deleted if they are... (5 Replies)
Discussion started by: ssachins
5 Replies

6. Shell Programming and Scripting

Delete files older than 2 days using shell script in Unix

I'm new to shell script.... can any one help... What is the shell script to delete the files older than 2 days ? (3 Replies)
Discussion started by: satishpabba
3 Replies

7. UNIX for Dummies Questions & Answers

List out last 2 days files using shell command

Could please help me To view removed files list for last 2 days. (1 Reply)
Discussion started by: santhakumar
1 Replies

8. Shell Programming and Scripting

Error While Purging Files

find /filearchive/ -type f -mtime +7 -exec rm weblogs*.log {} \; This worked only if this comand is executed int he unix comand prompt, but when i put this in the shell script it is not recognizing the file.It says weblogs: No such file or directory Am i doing anything wrong here ? (4 Replies)
Discussion started by: svishh123
4 Replies

9. Shell Programming and Scripting

Purging a Set of Files

Hi Frineds, I want to delete a set of files which are older than 7 days from teh current date.I am totally enw to shell scripting, can anyone help me with a sample code to list out the files which are older and then remove them from the directory. Please help THanks Viswa (5 Replies)
Discussion started by: svishh123
5 Replies

10. Shell Programming and Scripting

Purging script

Hi, Need to change the following command to also purge the child directories after /data/tmp within one command (recursively check for X number of days old files and purge accordingly)? e.g. /data/tmp/a, /data/tmp/a/b, /data/tmp/log. find /data/tmp -type f -mtime +7 -exec rm -f {} \; ... (2 Replies)
Discussion started by: egls
2 Replies
Login or Register to Ask a Question