Clean Up Oracle archive log using cron ————————————– Cron List Oracle has capability for creating hot backup using archive log mechanism. This feature act like recovery data system for restoring database content to specified time if the original database has force major which make data corrupted. But, this mechanism will suck up the free space of hard disk and typically if we don’t maintain the following problem maybe occured : 1. The Space allocated for archive run out which make all transaction will be suspended 2. Hard disk space will be run out Usually we can delete completed archive log using RMAN command, but this sometimes takes time. Below is automation script for deleting completed archive log using cron. 1. create script (named cleanarchive.sh) #!/bin/bash export ORACLE_BASE=/database/oracle/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_OWNR=oracle export ORACLE_SID=orcl export PATH=$PATH:$ORACLE_HOME/bin su – oracle -c rman target / </database/oracle/crontab/arch.log 2>&1 3. Restart cron service Voila …, now the completed archive log will be checked and cleaned up every day, and we just left the archive less then 7 day till the day executed.

Clean Up Oracle archive log using cron
————————————–
Cron List

Oracle has capability for creating hot backup using archive log mechanism. This feature act like recovery data system for restoring database content to specified time if the original database has force major which make data corrupted.

But, this mechanism will suck up the free space of hard disk and typically if we don’t maintain the following problem maybe occured :

1. The Space allocated for archive run out which make all transaction will be suspended

2. Hard disk space will be run out

Usually we can delete completed archive log using RMAN command, but this sometimes takes time.

Below is automation script for deleting completed archive log using cron.

1. create script (named cleanarchive.sh)

#!/bin/bash
export ORACLE_BASE=/database/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin

su – oracle -c rman target / << __EOF__
DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE ‘SYSDATE -7’;
EXIT
__EOF__

2. create new job on cron sequence (will be executed everyday at 22:55)

crontab -e

55 22 * * * /bin/sh /database/oracle/crontab/cleanarchive.sh >/database/oracle/crontab/arch.log 2>&1

3. Restart cron service

Voila …, now the completed archive log will be checked and cleaned up every day, and we just left the archive less then 7 day till the day executed.

Advertisements
Previous Post
Next Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: