sh 스크립트 끝에는 더 깔끔해야 하는 "case" 루프가 있지만 사용 중인 코드 아래에서는 그렇지 않습니다.
TARGET_DMPDIR=`sqlplus -s "/as sysdba" <<EOF
SET PAGESIZE 0
SET LINESIZE 200
SET HEADING OFF
SET FEEDBACK OFF
SET TRIMSPOOL ON
SET FEED OFF
SET VERIFY OFF
select directory_path from dba_directories where directory_name='DATA_PUMP_DIR';
exit;
EOF`
DATE=`date +"%Y%m%d-%H%M%S"`
COMPRESSED_EXPORTFILE="${ORACLE_SID}_${DATE}.dmp" (before the export)
COMPRESSED_EXPORTFILE=${COMPRESSED_EXPORTFILE}.Z (after export)
case "$ORACLE_SID" in
LIVE) t=6 ;;
*) t=1 ;;
esac
find "$TARGET_DMPDIR" -type f '(' -name "$COMPRESSED_EXPORTFILE" -o -name "exp_*_$ORACLE_SID.log" ')' \
-mtime +"$t" -print -exec rm {} \;
이것이 내 TARGET_DMPDIR에 있는 내용입니다.
-rw-r----- 1 oracle dba 814252 Mar 7 21:08 LIVE_20180307-210159.dmp.Z
-rw-r----- 1 oracle dba 819516 Mar 8 21:09 LIVE_20180308-210202.dmp.Z
-rw-r----- 1 oracle dba 814493 Mar 9 21:08 LIVE_20180309-210158.dmp.Z
-rw-r--r-- 1 oracle dba 3167 Mar 9 21:08 exp_20180309_LIVE.log
-rw-r----- 1 oracle dba 820402 Mar 10 21:08 LIVE_20180310-210157.dmp.Z
-rw-r--r-- 1 oracle dba 3169 Mar 10 21:08 exp_20180310_LIVE.log
-rw-r----- 1 oracle dba 822035 Mar 11 21:08 LIVE_20180311-210158.dmp.Z
-rw-r--r-- 1 oracle dba 3169 Mar 11 21:08 exp_20180311_LIVE.log
-rw-r----- 1 oracle dba 814219 Mar 12 21:08 LIVE_20180312-210157.dmp.Z
-rw-r--r-- 1 oracle dba 3169 Mar 12 21:08 exp_20180312_LIVE.log
-rw-r----- 1 oracle dba 21725862211 Mar 14 00:13 LIVE_20180313-212553.dmp.Z
-rw-r--r-- 1 oracle dba 172259 Mar 14 00:13 exp_20180313_LIVE.log
-rw-r----- 1 oracle dba 21751392439 Mar 15 00:13 LIVE_20180314-212558.dmp.Z
-rw-r--r-- 1 oracle dba 172259 Mar 15 00:13 exp_20180314_LIVE.log
-rw-r----- 1 oracle dba 21773328817 Mar 16 00:14 LIVE_20180315-212518.dmp.Z
-rw-r--r-- 1 oracle dba 172259 Mar 16 00:14 exp_20180315_LIVE.log