← Space Management
Oracle · Space Management

How to clean up trace (.trc / .trm) files in Oracle

Reclaim disk space by finding and deleting old Oracle trace files (.trc) and trace metadata files (.trm) under the diagnostic destination.

Tested on11g12c18c19c21c23ai26ai

Trace files land under $ORACLE_BASE/diag/rdbms/<db>/<instance>/trace and can silently fill /u01. Delete files older than N days (typical: 3–30 depending on retention policy), preview first with ls, then verify with df.

Deletes trace files permanently. If a large single trace (many GB) is from an ongoing incident, save it or copy the tail before removing.

# 1) Go to the trace directory of the target instance
cd $ORACLE_BASE/diag/rdbms/<db>/<instance>/trace
pwd

# 2) Preview trace files older than N days (adjust N)
find . -name '*.trc' -type f -mtime +3 -exec ls -lh {} \;
find . -name '*.trm' -type f -mtime +3 -exec ls -lh {} \;

# 3) Delete them
find . -name '*.trc' -type f -mtime +3 -exec rm -f {} \;
find . -name '*.trm' -type f -mtime +3 -exec rm -f {} \;

# 4) Handle a single giant trace file: keep only the last 5000 lines
#    (useful when you cannot afford to lose recent context)
BIG=/full/path/to/BIG_FILE.trc
tail -5000 "$BIG" > "$BIG.copy"
cp -f  "$BIG.copy" "$BIG"
cat /dev/null > "$BIG.copy"
rm -f "$BIG.copy"

# 5) Verify freed space
df -kh .
housekeepingtracetrctrmdisk space