Find and Remove Trash Files

#!/bin/bash

PATH=$PATH:.:/etc; export PATH

ALERT_TRACE=/u01/app/oracle/diag/rdbms/orcl/orcl/trace; export ALERT_TRACE
LI_TRACE=/u01/app/logs/diag/tnslsnr/pacemaker-1/listener_orcl/trace; export LI_TRACE
ORACLE_SID=orcl; export ORACLE_SID

[[ -d "/u01/app/logs" ]] || echo "No trace directory!!!" && exit 0

echo "Deleting: $ORACLE_SID - trace log files"

# Copy current trace file
cp -p $ALERT_TRACE/alert_$ORACLE_SID.log $ALERT_TRACE/alert_$ORACLE_SID."$(date +%y%m%d)"
cp -p $LI_TRACE/listener_$ORACLE_SID.log $LI_TRACE/listener_$ORACLE_SID."$(date +%y%m%d)"

# Create new trace file
> $ALERT_TRACE/alert_$ORACLE_SID.log
> $LI_TRACE/listener_$ORACLE_SID.log

# Find and remove alert trace file older than 30 days
find $ALERT_TRACE -type f -mtime +1 -exec rm -f {} \;

# Find and remove listener trace file older than 14 days
find $LI_TRACE -type f -mtime +1 -exec rm -f {} \;

echo "Finished delete: $ORACLE_SID - trace log files"