find /archive_log \( -ctime +7 -name '*.arc' \) -exec rm -f {} \;
또다른 방법은 가장 최신의 파일만 남겨두고 삭제하는 쉘스크립트이다. 아래 블로그 참고.
http://kkckc.tistory.com/41
내용은 다음과 같다.
#!/bin/bash
# this script used for delete all files in directory but recent one
# made for delete oracle archive files
# you can set the directory what you check and delete
export ARCH_DIR="/kkckc/archDir"
# set the file extension what you want (ex:arc)
export FILE_EXT="arc"
count=0
while :
do
FILES=$(ls -lrt $ARCH_DIR/*.$FILE_EXT | awk {'print $9'})
count=0
tcount=0
for file in $FILES; do
let "count+=1"
done
for file in $FILES; do
let "tcount+=1"
if [ "$tcount" -ne "$count" ]
then
echo "DELETE $file"
rm -rf $file
fi
done
sleep 10
done
#echo "COUNT:$count"
댓글 없음:
댓글 쓰기