본문 바로가기
조회 수 5411 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
yum install -y logrotate

vi /etc/logrotate.d/rails
------------------8<--------------------
/home/shareuser/html_public/log/*log
{
    notifempty
    rotate 52
    compress
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
------------------8<--------------------
logrotate -f /etc/logrotate.conf
ls -l /home/shareuser/html_public/log/
02.png

Note: options

daily – Rotate the log files each day. You can also use weekly or monthly here instead.
missingok – If the log file doesn’t exist, ignore it
rotate 7 – Only keep 7 days of logs around
compress – GZip the log file on rotation
delaycompress – Rotate the file one day, then compress it the next day so we can be sure that it won’t interfere with the Rails server
notifempty – Don’t rotate the file if the logs are empty
copytruncate – Copy the log file and then empties it. This makes sure that the log file Rails is writing to always exists so you won’t get problems because the file does not actually change. If you don’t use this, you would need to restart your Rails application each time.

Note: List The Contents (Files) Of A Package

yum -y install yum-utils
repoquery -q -l logrotate
01.png

- 주요파일
/etc/cron.daily/logrotate
/etc/logrotate.conf
/etc/logrotate.d
/usr/sbin/logrotate

Note: default logrotate configuration files


/etc/logrotate.conf (글로벌 설정파일)
------------------8<--------------------
# rotate log files weekly
weekly <-------- 로그파일을 매주주기로 순환

# keep 4 weeks worth of backlogs
rotate 4 <-------- logrotate의 결과 삭제되거나 지정된 주소로 메일로 보내지기 전의 총 파일갯수

[...]

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

[...]
------------------8<--------------------

/etc/logrotate.d/syslog
------------------8<--------------------
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    sharedscripts
    postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
------------------8<--------------------

/etc/logrotate.d/httpd
------------------8<--------------------
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
------------------8<--------------------


Title
List of Articles
번호 제목 글쓴이 날짜 조회 수
448 How to install Java on linux with no Internet connectivity (using local repository) Hojung 2015.12.22 3790
447 How to install tcpreplay on CentOS 6.5 Hojung 2015.08.21 8628
446 Install et131x network interface driver in CentOS 6 (LW25-BDUO3) file Hojung 2015.07.03 4933
445 How to find CentOS and kernel version Hojung 2015.04.30 4297
444 MD5 Test Hojung 2015.04.01 4463
443 MAC times in Linux (atime, mtime, ctime, crtime, touch, stat, debugfs) Hojung 2015.01.13 5383
442 How to generate a key with passphrase Hojung 2014.11.22 5642
441 Most Common OpenSSL Commands Hojung 2014.11.21 6091
440 How to use screen command Hojung 2014.11.17 4545
439 snorby (on testing) Hojung 2014.11.17 7293
438 APM (Apache + PHP + MySQL) with phpmyadmin in CentOS VM Hojung 2014.11.16 5434
437 10 Ways to Generate a Random Password from the Command Line Hojung 2014.11.16 4747
436 How to increase the size of a Linux LVM by adding a new disk file Hojung 2014.11.14 4942
» Configuring logrotate for Rails logs file Hojung 2014.11.13 5411
434 Installing Splunk on CentOS file Hojung 2014.10.31 7277
433 Web performance test with ab (ruby web, dd, ab) file Hojung 2014.10.01 6258
432 Web performance test with Pylot (ruby web, dd, pylot) file Hojung 2014.10.01 5801
431 Install and Configure NTP to Synchronize The System Clock (ntpd, ntpdate) Hojung 2014.09.17 5317
430 How to disable IPv6 in CentOS 6 Hojung 2014.09.04 5446
429 IDS with snort in CentOS (Snort, Barnyard2) Hojung 2014.08.19 8842
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 23 Next ›
/ 23

Designed by sketchbooks.co.kr / sketchbook5 board skin

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5