Solved

shell script

Posted on 2015-02-05
9
174 Views
Last Modified: 2015-06-23
I need help with shell script to clean up archivelog every 1 hour  

on unix solaris

rman  target /

delete archivelog all;
crosscheck archivelog all;
0
Comment
Question by:k khnn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 2

Accepted Solution

by:
Smita Melinmani earned 100 total points
ID: 40592695
I have not tested the script though. It would look like below:

#!/bin/sh
echo "####################################################" >/home/user/archivelogdelete.log
echo "Deleting the archivelogs at `date`"  >>/home/user/performance.log
echo "####################################################" >> /home/user/archivelogdelete.log
echo  "" /home/user/archivelogdelete.log

rman target=/ << EOF
RUN {
  delete archivelog all;
  crosscheck archivelog all;
}
EXIT;
EOF
echo "END ..." >/home/user/archivelogdelete.log

And you can schedule this job in cron every hour as below :

0 * * * * your_script_name
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 200 total points
ID: 40592718
>>clean up archivelog every 1 hour  

You are backing up the archived redo to tape before deleting them, right? If not, why are you in archive redo mode if you don't care about recovery?

My RMAN is a little rusty but I don't think you need to crossheck after a delete.  You normally do a crosscheck before a delete in case the files have been removed outside of RMAN.  The crosscheck tells RMAN to make sure what it thinks is on disk, actually is.

The above cron and script needs a little more:  The Oracle environment.  shell scripts executed from cron don't have the environment set up.

If everything is set up properly the additions below should work but I'm not on Unix where I can actually test them.

You'll need to change the ORACLE_SID and possibly the path to oraenv.

I also didn't change to order of delete and crosscheck.  I don't believe it is correct but cannot test.
#!/bin/sh
echo "####################################################" >/home/user/archivelogdelete.log
echo "Deleting the archivelogs at `date`"  >>/home/user/performance.log
echo "####################################################" >> /home/user/archivelogdelete.log
echo  "" /home/user/archivelogdelete.log

ORAENV_ASK=NO
export ORACLE_SID=ORCL
. /usr/local/bin/oraenv
rman target=/ << EOF
RUN {
  delete archivelog all;
  crosscheck archivelog all;
}
EXIT;
EOF
echo "END ..." >/home/user/archivelogdelete.log

Open in new window

0
 

Author Comment

by:k khnn
ID: 40592744
i am getting

ORACLE_SID= mydbsid   is not an identifier
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 200 total points
ID: 40592766
It depends on what shell /bin/sh really is.  It may not like the combined export command.

Change this:

export ORACLE_SID=ORCL

to this:

ORACLE_SID=ORCL
export ORACLE_SID
0
 

Author Comment

by:k khnn
ID: 40592907
When i manually delete archivelog it asks

do you really want o delete the above objects (enter yes or no)? Yes

how do add this in this shell?
0
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 200 total points
ID: 40593357
Change your command from DELETE to DELETE NOPROMPT

There are ways to do it with the shell script, but removing the prompt at the source is probably easier.
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 200 total points
ID: 40596169
>>ORACLE_SID= mydbsid   is not an identifier

There was also a space in there.
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 40845993
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question