?
Solved

shell script

Posted on 2015-02-05
9
Medium Priority
?
191 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
  • 2
  • 2
  • 2
  • +2
8 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 78

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
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!

 
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 78

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 23

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

Independent Software Vendors: 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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 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