Linux/Unix shell ???????鵵??????
???????????? ???????[ 2013/6/6 10:10:35 ] ????????
????????DEV???UAT????????Щ???????????????鵵??????????????????????????archive?鵵???????????????′????????????á????????????Σ???????????shell????????????????Щ?鵵??????????????????鵵?????????
????1??????鵵???shell???
robin@SZDB:~/dba_scripts/custom/bin> more remove_arch_dump.sh
#!/bin/bash
# ------------------------------------------------------------+
# FileName: remove_arch_dump.sh |
# Desc: |
# Remove old archived log and data pump file |
# Usage: |
# ./remove_arch_dump.sh |
# |
# Authror : Robinson |
# Blog :http://blog.csdn.net/robinson_0612 |
# ------------------------------------------------------------+
filename=/etc/oratab
cat $filename | while read LINE
do
case $LINE in
#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
echo $ORACLE_SID
# ---------------------------------
# define archived log directory
# ---------------------------------
dir=/u02/database/$ORACLE_SID/archive/
echo $dir
filelist=`ls -t $dir`
echo $filelist
# ----------------------------------------------------------
# start to remove archived log and keep last 2 archived log
# ----------------------------------------------------------
count=0
for filename in $filelist
do
echo $filename
count=$(($count+1))
if [ $count -gt 2 ]; then
echo $count
rm -vrf $dir$filename
fi
done
ls -tr $dir
# --------------------------------
# define data pump dump directory
# --------------------------------
dir=/u02/database/$ORACLE_SID/BNR/dump/
echo $dir
filelist=`ls -t $dir`
echo $filelist
# ---------------------------------------------------------
# start to remove data pump file and keep last 5 dump file
# ---------------------------------------------------------
count=0
for filename in $filelist
do
echo $filename
count=$(($count+1))
if [ $count -gt 5 ]; then
echo $count
rm -vrf $dir$filename
fi
done
ls -tr $dir
;;
esac
done
exit
????2????????
????a???y??????????????????oratab?ж??????????SID?????????????鵵???·?????datapump dump·????
????b??????????for?????????鵵????????????2???鵵????????
????c???????????????for???????????????SID??????dump(Oracle datapump)???μ?????dump?????
????d???????鵵?????????趨?????dump??????5??????????????????????(dump??5??????鵵???2)????????
????e?????????????dump·?????????dump?????????
????f???????????????crontab??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11