Solved

shell script

Posted on 2015-02-05
9
171 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
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 76

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

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 34

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Via a live example, show how to take different types of Oracle backups using RMAN.
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.

839 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