Mir Sayeed Hassan – Oracle Blog

Oracle DBA – Tips & Techniques | Learn with real-time examples

  • Translate

  • It’s Me






  • My Certificates

  • Links

    My Acclaim Certification : Credly Profile
    My Oracle ACE Pro Profile

  • Achievements

    Awarded Top 100 Oracle Blogs from Worldwide - #RANK 39
  • VISITORS COUNT

  • Verified International Academic Qualification from World Education Service (WES)

    Verified International Academic Qualification from World Education Service (WES)

  • Jobs

Find out the method to delete the existing/old log files automatically by using the ADRCI Utility in Oracle 19C Database.

Posted by Mir Sayeed Hassan on March 30th, 2025

Find out the method to delete the existing/old log files automatically  by using the ADRCI Utility in Oracle 19C Database.

Brief: To delete the existing/old log files from the database, there are 2 method to perform this operation

1-Manual

Traditional method to delete the old log files (alert, trace,.xml,.aud files) as discuss in below link.

Script to Delete Log Files in Oracle Database by using the Crontab Job

2. Automatically method., i’m going to discuss in this article.

Check the status of database

SYS @ ora19cdb > select instance_name, version, open_mode from V$database, v$instance;

INSTANCE_NAME     VERSION        OPEN_MODE
---------------- ----------------- --------------------
ora19cdb         19.0.0.0.0      READ WRITE

– The adrci (Automatic Diagnostic Repository Command Interface) is a command-line tool in Oracle used for managing diagnostic data stored in the Automatic Diagnostic Repository (ADR).
– ADR is a file-based repository that stores trace files, alert logs, core dumps, and incident reports.

To start adrci, simply run in bash

[oracle@ora19c ~]$ adrci

ADRCI: Release 19.0.0.0.0 - Production on Sun Mar 30 06:42:57 2025

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

ADR base = "/u01/app/oracle"
adrci>

To get more familiar with adrci command issue ” help”

adrci> help

HELP [topic]
Available Topics:
CREATE REPORT
ECHO
ESTIMATE
EXIT
HELP
HOST
IPS
PURGE
RUN
SELECT
SET BASE
SET BROWSER
SET CONTROL
SET ECHO
SET EDITOR
SET HOMES | HOME | HOMEPATH
SET TERMOUT
SHOW ALERT
SHOW BASE
SHOW CONTROL
SHOW HM_RUN
SHOW HOMES | HOME | HOMEPATH
SHOW INCDIR
SHOW INCIDENT
SHOW LOG
SHOW PROBLEM
SHOW REPORT
SHOW TRACEFILE
SPOOL

There are other commands intended to be used directly by Oracle, type
“HELP EXTENDED” to see the list

Check the current all ADR homes.

adrci> show base
ADR base is "/u01/app/oracle"
adrci> show homes
ADR Homes:
diag/rdbms/ora19cdb/ora19cdb
diag/clients/user_oracle/host_7007864_82
diag/clients/user_oracle/host_3750421121_82
diag/clients/user_oracle/host_3750421121_110
diag/clients/user_oracle/RMAN_3750421121_110
diag/tnslsnr/oemdb/listener
diag/tnslsnr/oemdb/istener1
diag/tnslsnr/oemdb/listener1
diag/tnslsnr/oem13/listener
diag/asmcmd/user_oracle/oemdb
diag/kfod/oemdb/kfod

Set the ADR Home

adrci> set home diag/rdbms/ora19cdb/ora19cdb

Verify

adrci> show home
ADR Homes:
diag/rdbms/ora19cdb/ora19cdb

Check the old files for the directory

[oracle@ora19c ~]$ cd /u01/app/oracle/diag/rdbms/ora19cdb/ora19cdb/trace/
[oracle@ora19c trace]$ ls -ltra | head -15

total 138880
drwxr-x---. 16 oracle oinstall 4096 Mar 24 2024 ..
-rw-r-----. 1 oracle oinstall 1453 Feb 27 10:14 ora19cdb_m002_122995.trm
-rw-r-----. 1 oracle oinstall 38911 Feb 27 10:14 ora19cdb_m002_122995.trc
-rw-r-----. 1 oracle oinstall 2956 Feb 27 11:34 ora19cdb_m005_29462.trm
-rw-r-----. 1 oracle oinstall 149548 Feb 27 11:34 ora19cdb_m005_29462.trc
-rw-r-----. 1 oracle oinstall 1619 Feb 27 16:55 ora19cdb_m004_126532.trm
-rw-r-----. 1 oracle oinstall 54670 Feb 27 16:55 ora19cdb_m004_126532.trc
-rw-r-----. 1 oracle oinstall 1433 Feb 27 20:25 ora19cdb_m001_24043.trm
-rw-r-----. 1 oracle oinstall 38854 Feb 27 20:25 ora19cdb_m001_24043.trc
-rw-r-----. 1 oracle oinstall 1834 Feb 27 20:35 ora19cdb_m000_2588.trm
-rw-r-----. 1 oracle oinstall 70490 Feb 27 20:35 ora19cdb_m000_2588.trc
-rw-r-----. 1 oracle oinstall 1715 Feb 28 01:25 ora19cdb_m003_13400.trm
-rw-r-----. 1 oracle oinstall 60990 Feb 28 01:25 ora19cdb_m003_13400.trc
-rw-r-----. 1 oracle oinstall 1692 Feb 28 03:35 ora19cdb_m002_24112.trm

Let us configure to delete files older than 5 days (120 hours).

adrci> set control (SHORTP_POLICY=168)
adrci> set control (LONGP_POLICY=1080)
adrci> select SHORTP_POLICY,LONGP_POLICY from ADR_CONTROL;

ADR Home = /u01/app/oracle/diag/rdbms/ora19cdb/ora19cdb:
*************************************************************************
SHORTP_POLICY     LONGP_POLICY
-------------------- ----------
168                 1080

1 row fetched

Note: The default policy for SHORTP_POLICY is 30 days & LONGP_POLICY is 365days.

Verify the LAST_AUTOPRG_TIME to Ensure Automatic Deletion is Run

An empty LAST_AUTOPRG_TIME field in the output indicates that no deletions have been made automatically.

adrci> select SHORTP_POLICY,LONGP_POLICY,LAST_AUTOPRG_TIME from ADR_CONTROL;

ADR Home = /u01/app/oracle/diag/rdbms/ora19cdb/ora19cdb:
*************************************************************************
SHORTP_POLICY     LONGP_POLICY    LAST_AUTOPRG_TIME
-------------------- -------------------- ----------------------------------------
168               1080            2025-03-29 07:15:41.506415 -04:00

and also you can also issue the “show control”

adrci> show control

Check the Directory to ensure log files are Deleted as per the above policy set

[oracle@ora19c ~]$ cd /u01/app/oracle/diag/rdbms/ora19cdb/ora19cdb/trace
[oracle@ora19c trace]$ ls -ltra | head -15
total 138884
drwxr-x---. 16 oracle oinstall 4096 Mar 24 2024 ..
-rw-r-----. 1 oracle oinstall 1453 Feb 27 10:14 ora19cdb_m002_122995.trm
-rw-r-----. 1 oracle oinstall 38911 Feb 27 10:14 ora19cdb_m002_122995.trc
-rw-r-----. 1 oracle oinstall 2956 Feb 27 11:34 ora19cdb_m005_29462.trm
-rw-r-----. 1 oracle oinstall 149548 Feb 27 11:34 ora19cdb_m005_29462.trc
-rw-r-----. 1 oracle oinstall 1619 Feb 27 16:55 ora19cdb_m004_126532.trm
-rw-r-----. 1 oracle oinstall 54670 Feb 27 16:55 ora19cdb_m004_126532.trc
-rw-r-----. 1 oracle oinstall 1433 Feb 27 20:25 ora19cdb_m001_24043.trm
-rw-r-----. 1 oracle oinstall 38854 Feb 27 20:25 ora19cdb_m001_24043.trc
-rw-r-----. 1 oracle oinstall 1834 Feb 27 20:35 ora19cdb_m000_2588.trm
-rw-r-----. 1 oracle oinstall 70490 Feb 27 20:35 ora19cdb_m000_2588.trc
-rw-r-----. 1 oracle oinstall 1715 Feb 28 01:25 ora19cdb_m003_13400.trm
-rw-r-----. 1 oracle oinstall 60990 Feb 28 01:25 ora19cdb_m003_13400.trc
-rw-r-----. 1 oracle oinstall 1692 Feb 28 03:35 ora19cdb_m002_24112.trm

Note: There is one question arrises here as is there any possibility to Change ADR Automatic Purge Scheduled Time? as set above.

therefore., there is no control on the purge frequency, it is fixed to be 48 hours after startup & then every 7days., Only way is in manual purge where you can control action in between.

Manual method of deleting trace and alert files

adrci> purge -age 2880 -type trace
adrci> purge -age 2880 -type alert

Note: Manually it deletes older than 2 days trace files & alert files.

Some of the mainly adrci command used for analysis are:

adrci> show alert

Check Errors

adrci> show problem
adrci> show incident

Check Trace Files

adrci> show tracefile
adrci> show tracefile -rt

Hence tested and verified in our test env.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>