Share

Managing and Purging Oracle Diagnostic Files Using Automatic Diagnostic Repository Command Interpreter

Oracle Database and its associated components generate various diagnostic files to support troubleshooting, performance analysis, and incident investigation.

These files include:

  • Alert logs
  • Trace files
  • Incident files
  • Core dump files
  • Health Monitor reports
  • Listener diagnostic logs

Over time, these diagnostic files can consume a significant amount of disk space, particularly in environments running multiple Oracle Database instances, Oracle Grid Infrastructure, and Oracle RAC.

Manually identifying and deleting these files from individual directories is not recommended. Oracle provides a dedicated utility called ADR Command Interpreter (ADRCI) to manage the Automatic Diagnostic Repository (ADR).

ADRCI enables database administrators to inspect diagnostic information, purge obsolete files, and configure automatic retention policies.

This article explains how to use ADRCI to manage and clean up Oracle diagnostic files efficiently.

Understanding the Automatic Diagnostic Repository (ADR)

The Automatic Diagnostic Repository (ADR) is a centralized directory structure used by Oracle to store diagnostic data for database and infrastructure components.

Depending on the Oracle component, ADR stores diagnostic information under different ADR homes.

Typical ADR locations include:

  • Database instances
  • Oracle ASM instances
  • Oracle Grid Infrastructure
  • Oracle Net Listener
  • Oracle client applications

Before using ADRCI, ensure that the Oracle environment has been initialized and that the ORACLE_BASE environment variable is configured correctly.

For example:

$ . oraenv

ORACLE_SID = [+ASM1] ? +ASM1

The Oracle base remains unchanged with value /u01/app/oracle

$ adrci

Example ADRCI startup output:

ADRCI: Release 11.2.0.4.0 - Production




Copyright (c) 1982, 2011, Oracle and/or its affiliates.

All rights reserved.




ADR base = "/u01/app/oracle"

Listing Available ADR Homes

An Oracle environment may contain multiple ADR homes, depending on the installed components and running instances.

To display all available ADR homes, execute:

adrci> show homes

Example output:

ADR Homes:

diag/asm/+asm/+ASM1

diag/clients/user_oracle/host_2585172500_11

diag/clients/user_oracle/host_2585172500_80

diag/diagtool/user_oracle/host_2585172500_11

diag/rdbms/orcltest/ORCLTEST1

diag/rdbms/audit/AUDIT1

diag/rdbms/orcl/ORCL1

diag/tnslsnr/oradb1/listener

 

Each entry represents a separate diagnostic repository location.

To perform maintenance operations, first select the appropriate ADR home.

For example, to manage Oracle Listener diagnostic files:

adrci> set home diag/tnslsnr/oradb1/listener

 

Important: ADRCI operations are performed against the selected ADR home. Always verify the active home before executing purge commands.

Manually Purging Diagnostic Files

ADRCI provides the PURGE command to remove diagnostic files older than a specified retention period.

The retention period is specified in minutes.

For example, to delete Listener trace and alert files older than one day:

adrci> purge -age 1440 -type TRACE

adrci> purge -age 1440 -type ALERT

The following command types can be used with the PURGE operation:

Type Description
ALERT Alert log files
INCIDENT Incident diagnostic files
TRACE Trace files
CDUMP Core dump files
UTSCDMP User trace dump files
STAGE Diagnostic staging files
SWEEP Sweep directory files
HM Health Monitor files and associated metadata
IPS Incident Packaging Service files and associated metadata

For example, to purge diagnostic files older than seven days from the selected ADR home:

adrci> purge -age 10080

Here:

  • -age specifies the retention threshold in minutes.
  • 10080 represents seven days (7 × 24 × 60).

When no specific file type is provided, ADRCI applies the purge operation to the eligible diagnostic data types.

Configuring Automatic ADR Purge Policies

In addition to manual cleanup, ADR supports automatic diagnostic file retention policies.

These policies determine how long Oracle retains diagnostic information before it becomes eligible for automatic purging.

Two important parameters control the retention periods:

  • SHORTP_POLICY: Controls the retention period for incident and Health Monitor diagnostic data.
  • LONGP_POLICY: Controls the retention period for trace files, core dumps, and other long-term diagnostic data.

Both parameters are specified in hours.

To inspect the current retention configuration, execute:

adrci> set home diag/tnslsnr/oradb1/listener

adrci> show control

Example output:

ADR Home = /u01/app/oracle/diag/tnslsnr/oradb1/listener:


ADRID                SHORTP_POLICY LONGP_POLICY

-------------------- ------------- ------------

3953762085           720           8760

In this example:

  • SHORTP_POLICY = 720 means 30 days.
  • LONGP_POLICY = 8760 means 365 days.

To configure both policies to retain diagnostic information for seven days:

adrci> set control (SHORTP_POLICY = 168)

adrci> set control (LONGP_POLICY = 168)

Verify the updated configuration:

adrci> show control

 

The updated values should be:

SHORTP_POLICY = 168

LONGP_POLICY  = 168

Note: Changing retention policies does not necessarily mean that all existing files are deleted immediately. Files become eligible for automatic purging according to ADR maintenance operations. You can also execute a manual purge when required.

Applying ADR Retention Policies Across All ADR Homes

In environments running Oracle RAC or Oracle Grid Infrastructure, managing ADR retention policies individually can become time-consuming.

Instead of configuring each ADR home manually, administrators can automate the process using a shell script.

The following script iterates through the available ADR homes, applies seven-day retention policies, and executes the purge operation.

Script: adrci_set_policy.sh

#!/bin/bash

for ADRHOME in $(adrci exec="show homes")

do

    if [ "$ADRHOME" = "ADR" ] || [ "$ADRHOME" = "Homes:" ]

    then

        continue

    fi

    echo "Processing ADR Home: $ADRHOME"

    adrci <<EOF

set home $ADRHOME

set control (SHORTP_POLICY = 168)

set control (LONGP_POLICY = 168)

purge

exit

EOF

Done

 

Grant execution permission:

chmod +x adrci_set_policy.sh

 

 

Execute the script using the appropriate Oracle software owner:

./adrci_set_policy.sh

 

 

The script performs the following operations for each ADR home:

  1. Retrieves the available ADR homes.
  2. Selects each ADR home individually.
  3. Sets the short-term retention policy to 168 hours.
  4. Sets the long-term retention policy to 168 hours.
  5. Executes the purge operation.
  6. Continues with the next ADR home.

This approach simplifies diagnostic file maintenance across multiple Oracle components.

Operational Recommendations and Best Practices

When managing ADR diagnostic files in production environments, consider the following recommendations:

  1. Avoid manual file deletion

Do not directly remove diagnostic files using operating system commands such as rm. Use ADRCI whenever possible to maintain consistency between diagnostic files and ADR metadata.

  1. Review retention requirements

A seven-day retention period may be appropriate for some environments, but production systems with strict auditing, troubleshooting, or support requirements may need longer retention periods.

  1. Verify the ADR home

Always check the selected ADR home before running purge operations, especially on RAC and Grid Infrastructure environments.

  1. Automate maintenance

Schedule ADR cleanup scripts through an operating system scheduler such as cron, where appropriate.

  1. Preserve diagnostic information

Before purging diagnostic files following a critical incident, ensure that the relevant trace files, incident information, and alert logs have been collected if they may be required for further investigation or an Oracle Support Service Request.

  1. Monitor filesystem capacity

Regularly monitor the filesystem containing ORACLE_BASE and ADR directories to prevent diagnostic file accumulation from affecting database operations.

 

Conclusion

ADRCI is an essential utility for Oracle Database Administrators who need to manage diagnostic information efficiently.

By using ADRCI’s purge functionality and configuring appropriate retention policies, administrators can prevent unnecessary diagnostic file accumulation and maintain better control over filesystem utilization.

Automating ADR maintenance across all ADR homes is particularly useful in large-scale Oracle environments, including RAC and Grid Infrastructure deployments.

A properly configured ADR retention strategy helps maintain a clean, manageable, and operationally efficient Oracle infrastructure.

 

Loading

You may also like