With ADRCI, it is possible to delete files such as “log, trace, incident, cdump” created before a certain day. Instead of manually deleting individual files, you can do this very easily using adrci.
You must have set Oracle Base to use ADRCI. You can find detailed information about the use of this tool in the article “ADR Command Interpreter (ADRCI)“.
Start ADRCI:
1 2 3 4 5 6 7 8 9 10 |
-bash-4.3$ . oraenv ORACLE_SID = [+ASM1] ? +ASM1 The Oracle base remains unchanged with value /u01/app/oracle -bash-4.3$ adrci ADRCI: Release 11.2.0.4.0 - Production on Tue May 16 16:19:40 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. ADR base = "/u01/app/oracle" |
Then you should list the available homes and set a home. The example shows the steps required to delete listener alert files.
List of available homes:
1 2 3 4 5 6 7 8 9 10 |
adrci> show homes 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 |
Set home:
1 |
adrci> set home diag/tnslsnr/oradb1/listener |
Deleting previous Trace and ALERT files created before 3600 minutes(1 day) in set home:
1 2 |
adrci> purge -age 3600 -type TRACE adrci> purge -age 3600 -type ALERT |
It is possible to delete the following file types with the same command:
- ALERT – files in ./alert directory
- INCIDENT — files in ./incident/incdir_<incid> directory
- TRACE — files in ./trace directory
- CDUMP — files in ./cdump directory
- UTSCDMP — ./trace/cdmp_<timestamp> directories
- STAGE — files in ./stage directory
- SWEEP — files in ./sweep directory
- HM — files in the ./hm directory and metadata information in the HM schema
- IPS — files in the ./incpkg directory and the metadata information in the IPS schema
The following command can be used to delete all files:
1 |
adrci> purge -age 10080 |
These processes can be done automatically using the adrci tool.
Current policies need to be changed after the relevant home is set.
1 2 3 4 5 6 7 8 9 |
adrci> set home diag/tnslsnr/oradb1/listener adrci> show control ADR Home = /u01/app/oracle/diag/tnslsnr/oradb1/listener: ************************************************************************* ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME -------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ---------------------------------------- 3953762085 720 8760 2016-06-08 10:47:22.071463 +03:00 2017-05-16 16:20:48.104055 +03:00 1 2 80 1 2016-06-08 10:47:22.071463 +03:00 1 rows fetched |
An empty LAST_AUTOPRG_TIME field in the above output indicates that no deletions have been made automatically.
SHORTP_POLICY value should be changed for Incident and health monitor warnings and LONGP_POLICY value should be changed for trace and core dump files. The values here are in hours. It is observed that it will not erase for a very long time according to the current values. We need to make these values more acceptable. For example, files before a week can be deleted.
Set SHORTP_POLICY and LONGP_POLICY:
1 2 3 4 5 6 7 8 9 10 |
adrci> set control (SHORTP_POLICY = 168) adrci> set control (LONGP_POLICY = 168) adrci> show control ADR Home = /u01/app/oracle/diag/tnslsnr/oradb1/listener: ************************************************************************* ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME -------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ---------------------------------------- 3953762085 168 168 2017-05-16 16:58:40.865587 +03:00 2017-05-16 16:20:48.104055 +03:00 1 2 80 1 2016-06-08 10:47:22.071463 +03:00 1 rows fetched |
Instead of making this change one by one for each home, it is possible to do it at once with a script as follows.
adrci_set_policy.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/bin/sh for ADRHOME in `adrci exec="show home"` do if [ $ADRHOME = "ADR" -o $ADRHOME = "Homes:" ] then continue; fi echo $ADRHOME adrci <<EOF set home $ADRHOME set control (SHORTP_POLICY = 168) set control (LONGP_POLICY = 168) purge exit EOF done |