Clean archive log using RMAN in oracle RAC

Oracle RAC

The setup is a two node Oracle RAC with archive logging enabled. The archive logs are filling up the FRA, so i need to cleanup these logs automatically. When i write a simple script to cleanup, it works fine but it failed to do so after putting in crontab. I believe many people have faced the same issue, fix is very simple. Just execute the profile of oracle user before executing the script.

The below script will delete the archive logs older than 10 days. You can even modify the same script to take backups and delete backups. Since, this is RAC i only enable crontab in one node.

Crontab entry
[[email protected] scripts]$ crontab -l

Cleanup of archive logs

30 14 2,10,18,28 * * /home/oracle/scripts/clnarc.sh > /tmp/log.txt
[[email protected] scripts]$

Script with oracle profile & connecting to RMAN
[[email protected] scripts]$ cat clnarc.sh
. /home/oracle/.bash_profile
/data/app/oracle/product/11.2.0/dbhome_1/bin/rman target / @/home/oracle/scripts/rman_arch.sh
[[email protected] scripts]$

Commands for RMAN
[[email protected] scripts]$ cat rman_arch.sh
run {
delete noprompt archivelog until time ësysdate-10í;
}
[[email protected] scripts]$