#!/bin/bash
#make environment variable effect!
if [ -f ~/.bash_profile ] ;
then
source ~/.bash_profile;
fi
if [ -f ~/.profile ] ;
then
source ~/.profile;
fi
TMP_FILE=/tmp/`date +%Y%m%d`.txt
sqlplus -s / as sysdba << EOF
set pages 0
set feedback off
spool $TMP_FILE
select distinct value from v\$parameter
where name in
('audit_file_dest','background_dump_dest',
'core_dump_dest','user_dump_dest')
order by 1 ;
spool off
set feedback on
EOF
DIRS_CNT=`cat $TMP_FILE|wc -l`
for i in $(seq $DIRS_CNT);
do
##find `sed -n "${i}p" $TMP_FILE` -xdev -mtime +14 \( -name *.trc -o -name *.trm -o -name *.aud \)|xargs ls -l;
find `sed -n "${i}p" $TMP_FILE` -xdev -mtime +14 \( -name *.trc -o -name *.trm -o -name *.aud \)|xargs rm -rf;
done
rm -rf $TMP_FILE
-xdev : 只检查和指定目录在同一个文件系统下的文件,避免列出其它文件系统中的文件