How to Delete alert log files, Trace Files Automated in Oracle Database

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

Deleting  alert log files, Trace Files Automated in Oracle Database

[oracle@localhost ~]$ adrci

ADRCI: Release 12.1.0.2.0 - Production on Tue Mar 7 10:42:16 2018

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

ADR base = "/u01/app/grid"
adrci> show homes
ADR Homes:
diag/rdbms/_mgmtdb/-MGMTDB
diag/asm/+asm/+ASM2
diag/clients/user_root/host_1450230238_82
diag/clients/user_grid/host_1450230238_82
diag/crs/node2/crs
diag/tnslsnr/node2/mgmtlsnr
diag/tnslsnr/node2/listener
diag/tnslsnr/node2/listener_scan1
adrci> show homepath
ADR Homes:
diag/rdbms/_mgmtdb/-MGMTDB
diag/asm/+asm/+ASM2
diag/clients/user_root/host_1450230238_82
diag/clients/user_grid/host_1450230238_82
diag/crs/node2/crs
diag/tnslsnr/node2/mgmtlsnr
diag/tnslsnr/node2/listener
diag/tnslsnr/node2/listener_scan1
Set Current Home

This step is to set current workspace for all the following commands.

adrci> set homepath diag/crs/node2/crs
Show Current Configuration
adrci> show control

ADR Home = /u01/app/grid/diag/crs/node2/crs:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
3841422557 720 8760 2015-08-21 16:03:18.127927 +08:00 2018-03-07 10:43:49.850300 +08:00 1 2 82 1 2015-08-21 16:03:18.127927 +08:00
1 rows fetched

It displays various attributes of the ADR, including the short life (SHORTP_POLICY) and long life (LONGP_POLICY) purging policy attributes in hours.

Set Trace File Keep Time

1. SHORTP_POLICY: Number of hours after which to purge ADR contents that have a short life. Default is 720 (30 days).
2. LONGP_POLICY: Number of hours after which to purge ADR contents that have a long life. Default is 8760 (365 days).
adrci> set control (SHORTP_POLICY = 168)
adrci> set control (LONGP_POLICY = 672)
adrci> show control

ADR Home = /u01/app/grid/diag/crs/node2/crs:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
3841422557 168 672 2018-03-07 10:44:29.704205 +08:00 2018-03-07 10:43:49.850300 +08:00 1 2 82 1 2015-08-21 16:03:18.127927 +08:00
1 rows fetched

Which means we set the long life keep time as 28 days and the short life keep time as 7 days.
Delete Trace Files Immediately

adrci> purge -age 10080

This command can delete all trace files older than 10080 minutes (7 days) in current home immediately. You don’t have to wait background processes to do the job.

Leave a Reply

Your email address will not be published.