This content has been marked as final. Show 14 replies
set your ORACLE_SID to an ASM instance
using asmcmd locate the directory that contains the archive log files. for example..
ASMCMD> cd +POC2FLASH/POC2DWH/ARCHIVELOG
using 'rm' command you can delete the directory.
But don't forget to remove the archive log details from the control file or the RMAN catalog
For this you need to connect to the target database using rman
rman target sys/<password> nocatalog
rman>crosscheck archivelog all
rman>delete expired archivelog all
Message was edited by:
Thanks for quick reply.
This is what I am doing now, very manual process.
What I want is, setup an automatic job ( cron or other ) ,
to clean archive logs older than one day or one hour.
I am okay with RMAN solution,
if I don't have to backup these archive logs, before delete.
It is a very bad idea deleting archive logs via asmcmd, the controlfile-FRA code (space management) is not coginizant of this deletion since it was done outside its context.
You do not need to delete archive logs if the archlogs are stored in the Flash Area, since FRA will manage that.
But if you needed to delete manually delete these logs, then you should use RMAN for this. I dont recall the command off hand, but something along the lines of "delete archive logs backed up twice"
you need 2 scripts (modify paths accordingly as per your setup):
connect / as sysdba
set serveroutput on;
declare CURSOR cur IS
FROM v$asm_alias a, v$asm_file b
where a.group_number = b.group_number
and b.creation_date < sysdate-7
and a.file_number = b.file_number
and a.name like '%.arc'
order by a.name;
FOR cur_rec IN cur
sqlstr := 'alter diskgroup ASM_BACKUP drop file ''+ASM_BACKUP/DB1/' || cur_rec.name || '''';
EXECUTE IMMEDIATE sqlstr;
crosscheck archivelog all;
delete expired archivelog all;
If your whole objective is to clean the disk group, then you should really not bother about RMAN.
RMAN crosscheck will come in to picture when you want to backup archielogs in future, Oracle will always look for the archives which u already deleted using RM command or using alter disk group command but RMAN is not aware of these deletion.
RM or alter disk group command does not update your controlfile so you need to crosscheck whenever in future you want to backup the archivelogs.
You can query v$archived_log:deleted column to see if the controlfile is update or not.