
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 majeur 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/binsu – 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.
Tanjung Karang, Lampung
July, 1st 2012
Aah Ahmad Kusumah
How to achive same if you archive destination is on ASM for RAC?