로그인
Sign in
#!/bin/sh
#
# Program: Logfile rotation utility <logrotate.sh>
#
# Author: Matty <matty91 at gmail dot com>
#
# Current Version: 1.0
#
# Revision History:
#
# Version 1.0
#     Original release
#
# Last Updated: 10-09-2005
#
# Purpose:
#   This script will rotate the logfiles listed in the LOG variable. COUNT vopies
#   will be maintained.
#

# Set some global environment variables
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

# Trap signals sent when we are moving files so we don't get interrupted
trap '' 0 1 2 3 9 15

# GLOBAL VARIABLES
COUNT=10
LOGS="/var/adm/syslog/syslog.log /var/adm/syslog/mail.log /var/opt/resmon/log/event.log /var/adm/cron/log /var/adm/xferlog /var/adm/wtmp"
STOPVALUE=0

# LOOP till no more logs
for i in ${LOGS}
do
        # Reset the indice
        INDICE=${COUNT}
        while [ ${INDICE} -ge ${STOPVALUE} ]
        do
                # Add one to the present index
                PLUSONE=`expr ${INDICE} + 1`

                # if the logfile exists move it to LOG.INDEX + 1
                test -f ${i}.${INDICE} && mv ${i}.${INDICE} ${i}.${PLUSONE}

                # Increment the index
                INDICE=`expr $INDICE - 1`
        done

        # Move the logfile to logfile.COUNT
        mv ${i} ${i}.${STOPVALUE}

        # zero out the logfile ( NEW LOGFILE )
        cp /dev/null ${i}
        chmod 644 ${i}
done
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 자주 사용하는 명령어 제비게릴라 2019-06-27 20937
193 Nmon Analyser v33g – Excel 2010 64 bits file 하록 2012-08-07 6343
192 리눅스 테스트 프로그램 하록 2012-07-10 6494
191 hpux sshd 소스 컴파일시 하록 2012-07-09 7838
190 iscsi 설정 하록 2012-06-21 5451
189 리눅스 dm-0같은 볼륨 확인 방법 [1] 하록 2012-06-18 5944
188 php 파일 실행시 내용 보여줄때.. 하록 2012-03-14 5256
187 vi 한글 쓰기... [1] 하록 2011-12-08 5801
186 프로세스 별 Disk I/O 확인 방법 file 하록 2011-11-02 7221
185 sysrq 값에 대한 자료 하록 2011-11-01 6462
184 lsof 포트 확인 방법 하록 2011-10-26 6418
183 linux NTFS 사용... file 하록 2011-06-28 6377
182 사용중인 포트의 프로세스 찾기 하록 2011-06-02 5885
181 passwd, shadow 필드 설명 하록 2011-05-04 7097
180 hadoop 미사용 서버 확인.. 하록 2011-04-15 6373
179 Too many open files in system 해결 방법... 하록 2011-04-13 5893
178 rcmd: socket: All ports in use 하록 2011-04-07 7872
177 nfs - nfs fstab 형식과 옵션 하록 2011-03-28 6152
176 http error 메세지 하록 2011-03-25 6309
175 FTP Error 메세지... 하록 2011-03-25 6187
174 보안을 위한 /etc/sysctl.conf 파일 수정 하록 2011-03-22 6380