Home » Infrastructure » Linux » Deleting Old Archive logs
Deleting Old Archive logs [message #246064] Tue, 19 June 2007 13:43 Go to next message
Koolwant
Messages: 49
Registered: June 2007
Location: new jersey
Member
Hi experts


In my production database,I have to delete old archvie log files .I am always little scared to delete anything on production,but this time i have to .I am not using RMAN .
Can somebody tell me how to delete bunch of files (header or old ) files together.

Thanks

Kool
Re: Deleting Old Archive logs [message #246065 is a reply to message #246064] Tue, 19 June 2007 14:28 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
use it as example it leave latest 40 files and delete older,but before running it on PRODUCTION check it on DEV or TEST

# 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} > 40 )); then
     echo "Deleting ${count}; ${STATS_LOG_DIR}/${i}\n" >> $DEL_LOG
     rm ${STATS_LOG_DIR}/${i}
  fi
done


you can change it according to your requirment on your daily basis of archivelog generation.
Re: Deleting Old Archive logs [message #246070 is a reply to message #246064] Tue, 19 June 2007 15:02 Go to previous messageGo to next message
Koolwant
Messages: 49
Registered: June 2007
Location: new jersey
Member
Thanks for your reply DreamzZ

The solution you have given me is kind of difficult to understand for me .Can you please tell me what is DAILYLOGS,
STATS_LOG_DIR,DEL_LOG.I am kind of scared to delete files coz it is Production environment.and i dont have same data in test database to, so that i can test it on that.

Please can you suggest me over here

$>ls -ltra|head -40>>old_arch
then

rm old_arch

I am trying to do it this way but the files from arch get copied to old_arch file NOT Moved..What i wanna do is i wanna move old files to another file and then delete the whole file (or directory).

I am sorry if i am annoying you.

Regards

[Updated on: Tue, 19 June 2007 15:04]

Report message to a moderator

Re: Deleting Old Archive logs [message #246076 is a reply to message #246070] Tue, 19 June 2007 16:27 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
check this example

Quote:
1.11.8 Delete Files in Bulk
As a DBA, you sometimes need to remove older files from a filesystem. For example, you may want to remove older archived redo logs from your redo log filesystem in order to free up space for more current logs to be archived. You can do this with the help of the find command. The find command in the following example will identify all files that are more than seven days old:
>find . -mtime +7
./archlog251.arc.Z
./archlog252.arc.Z
./archlog253.arc.Z
./archlog254.arc.Z
Now that you have a list of files, you can use the find command's -exec argument to execute the rm command against each file that is found. For example:
find . -mtime +7 -exec rm {} \;
You can use this command to automatically remove all files that are more than seven days old. Note that -exec functions similarly to the xargs command shown earlier in this book.
Re: Deleting Old Archive logs [message #246077 is a reply to message #246076] Tue, 19 June 2007 16:32 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member

This command will find out files old than 3 days
 find . -mtime +3


And this command delete the files older than 3 days.

  find . -mtime +3 -exec rm {} \;
Re: Deleting Old Archive logs [message #246078 is a reply to message #246064] Tue, 19 June 2007 16:33 Go to previous messageGo to next message
Koolwant
Messages: 49
Registered: June 2007
Location: new jersey
Member
DREAMZZ YOU ARE "THE BEST"


The command find . -mtime +7 -exec rm {} \; worked

I am so happy .

And I appreciate your help.

Thanks a lot..

regards.
Re: Deleting Old Archive logs [message #246079 is a reply to message #246078] Tue, 19 June 2007 16:35 Go to previous message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
You welcome Wink
Previous Topic: export oracle user
Next Topic: Redhat linux
Goto Forum:
  


Current Time: Sat Dec 03 22:36:06 CST 2016

Total time taken to generate the page: 0.10416 seconds