백업 또는 아키이브한 디렉토리를 몇개만 남기고 오래된 것 부터 지워 버리기..

 

[XXXX] cat cleanup_archive.sh
#!/bin/sh
# This script is for cleanning up the archives
# $1 archive count

_file_lines=""
_archive="/usr02/bfuser/bin"
_count=0
_total=30

if [ $# -eq 1 ]; then
        _total=$1
else
        echo "Using default ${_total}"
fi
echo "Start deleting archive more than ${_total}"


_file_lines=`ls -alt ${_archive} | grep "RL" | awk '{print $9}'`
echo "${_file_lines}"

echo "Start Deleting.."
for file_name in ${_file_lines}
do
        _count=`expr ${_count} + 1`
        if [ ${_count} -gt ${_total} ]; then
                echo "Deleting.... ${_count} ${_archive}/${file_name}"
                rm -rf ${_archive}/${file_name}
        else
                echo "Skipping.... ${_count} ${_archive}/${file_name}"
        fi
done

이 글은 스프링노트에서 작성되었습니다.

Posted by 아프락사스
<< PREV : [1] : ... [50] : [51] : [52] : [53] : [54] : [55] : [56] : [57] : [58] : ... [160] : NEXT >>

BLOG main image

공지사항

카테고리

분류 전체보기 (160)
MAMP LAMP (1)
Open Project (4)
Knowhow (57)
JEE Technologies (3)
Rational Products (94)
Etc (0)