?
Solved

shell script

Posted on 2015-02-05
9
Medium Priority
?
177 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 400 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 800 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 800 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 800 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 800 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

752 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