Operating System - HP-UX
1752572 Members
4275 Online
108788 Solutions
New Discussion юеВ

create a script to delete old Oracle archive log files

 
SOLVED
Go to solution
Yvette Johnson
Advisor

create a script to delete old Oracle archive log files

Howdy! I need assistance with creating a script to delete old log files. Oracle creates archive log files. I want to keep files for at least 14 days and delete older files.

Thanks in advance for your help!!
17 REPLIES 17
Uday_S_Ankolekar
Honored Contributor
Solution

Re: create a script to delete old Oracle archive log files

You can run this one liner as a cronjob every day..

find dirname -type f -mtime +14 -exec rm {} \;

-USA..
Good Luck..
Yvette Johnson
Advisor

Re: create a script to delete old Oracle archive log files

Thanks for you help!
Yvette Johnson
Advisor

Re: create a script to delete old Oracle archive log files

I typed
find prod*.arc -type f -mtime +14 -exec rm{}\;

Results: find: -exec not terminated with ';'

What did I do wrong?
Pete Randall
Outstanding Contributor

Re: create a script to delete old Oracle archive log files

You need a space between the } and the \.


Pete

Pete
Yvette Johnson
Advisor

Re: create a script to delete old Oracle archive log files

I typed:
find prod*.arc -type f -mtime +14 -exec rm{ } \;

Results: Missing }.
Pete Randall
Outstanding Contributor

Re: create a script to delete old Oracle archive log files

I would also suggest that you use a full path name for the directory. You will probably want to run this from cron and cron has a pretty minimal environment so full path names are a necessity, even to the point of specifying /usr/bin/find rather than just find.


Pete

Pete
Yvette Johnson
Advisor

Re: create a script to delete old Oracle archive log files

I received this message from crontab when saving the file:

31 14 find /testing1/arch-prod/prod*.arc -type f -mtime +14 -exec rm{ } \;
crontab: error on previous line; unexpected character found in line.
Pete Randall
Outstanding Contributor

Re: create a script to delete old Oracle archive log files

Try
find /testing1/arch-prod -name 'prod*.arc' -type f -mtime +14 -exec rm{ } \;

instead.


Pete

Pete
Pete Randall
Outstanding Contributor

Re: create a script to delete old Oracle archive log files

Oh, and you've also got an extra space between your curly braces - it should be {} \; - that's curlybrace curleybrace space backslash semicolon.


Pete

Pete