°Ô½Ã¹° 260°Ç
   
[Red Hat] logrotate (·Î±×·ÎÅ×ÀÌÆ®)
±Û¾´ÀÌ : theko ³¯Â¥ : 2014-07-23 (¼ö) 08:56 Á¶È¸ : 8894
A. ·Î±×·ÎÅ×ÀÌÆ® ȯ°æ ¼³Á¤ ÆÄÀÏ¿¡ ´ëÇÑ ¼³¸í ÀÔ´Ï´Ù.

# cat /etc/logrotate.conf
# see "man logrotate" for details

# rotate log files weekly
weekly    // ·Î±×ÆÄÀÏÀ» º¯°æÇÒ ±â°£À» ¼³Á¤ÇÕ´Ï´Ù.
                  daily : ¸ÅÀÏ º¯°æ
                  weekly : ¸ÅÁÖ º¯°æ
                   monthly : ¸Å´Þ º¯°æ
                   yearly : ¸Å³â º¯°æ

# keep 3 weeks worth of backlogs
rotate 4    // ¼øȯµÉ ÆÄÀÏÀÇ °³¼ö¸¦ ¼³Á¤ÇÕ´Ï´Ù. 0ºÎÅÍ ½ÃÀÛÇÏ°Ô µÇ¸ç À§¿¡¼­ weekly·Î ¼³Á¤ ½Ã 4ÁÖ°£ º¸°üÇÕ´Ï´Ù.

# create new (empty) log files after rotating old ones
create    // ·Î±×ÆÄÀÏÀ» ¹é¾÷ÇÏ°í »õ·Î¿î ÆÄÀÏÀ» »ý¼ºÇÒ °ÍÀÎÁö ¼³Á¤ÇÕ´Ï´Ù.

# uncomment this if you want your log files compressed

#compress    // ¼øȯ(¹é¾÷)µÈ ·Î±×ÆÄÀÏÀ» ¾ÐÃàÇϵµ·Ï º¯°æÇÕ´Ï´Ù. ÁÖ¼®À» ÇØÁ¦ÇÏ¸é ¹é¾÷ÆÄÀÏÀ» gzipÀ¸·Î ¾ÐÃà ÇÕ´Ï´Ù.

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d    // ·Î±× ¼øȯ Á¤º¸¸¦ °¡Áø ÆÄÀϵéÀÌ ÀúÀåµÈ µð·ºÅ丮¸¦ ºÒ·¯ ¿É´Ï´Ù.
                                          ÀÌ µð·ºÅ丮¿¡ ÀÖ´Â ÆÄÀϵéÀÌ ¸ðµÎ Æ÷ÇԵ˴ϴÙ.

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp    //¼ÒÀ¯ÀÚ root, ±×·ì utmp
    rotate 6
}    // wtmp(Á¢¼Ó·Î±×ÆÄÀÏ, ¸í·É¾î last)¿¡ ´ëÇÑ ¼³Á¤À» ÇÕ´Ï´Ù. ÇÑ´Þ ´ÜÀ§·Î ¼øȯÀ» ÇÏ¸ç ¹é¾÷Àº ÇÑ´ÞÀ» º¸°üÇÏ°í
          ¹é¾÷ÆÄÀÏÀº root »ç¿ëÀÚ¿Í utmp±×·ìÀÇ ¼ÒÀ¯·Î 644Æ۹̼ÇÀ» ºÎ¿©ÇÕ´Ï´Ù.

# system-specific logs may be also be configured here.
 
B. /etc/logrotate.d µð·ºÅ丮¿¡ ³»¿ëÀ» Ãß°¡ÇÏ¿© ÆÄÀÏ·Î ¸¸µé¾î »ç¿ëÇÕ´Ï´Ù. ´ëÇ¥ÀûÀ¸·Î ¸î°³¸¸ »ìÆ캸°Ú½À´Ï´Ù.

[root@moon]# cat /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts    // ¿ÍÀϵåÄ«µå·Î ÁöÁ¤µÈ ¿©·¯ÆÄÀÏ¿¡ Àû¿ë ÇÕ´Ï´Ù.
    postrotate    // logrotate ÀÛ¾÷ ÀÌÈÄ¿¡ ÁöÁ¤µÈ ÀÛ¾÷(½ºÅ©¸³Æ®)¸¦ ½ÇÇà ÇÕ´Ï´Ù. ½ÃÀÛÁ¡
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
        /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript    // Á¾·áÁ¡
}


¹®ÀÇÇϽŠsecure ·Î±×¸¦ ÀϳⰣ ÀúÀå ÇÏ´Â ¹æ¹ýÀº ¿©·¯°¡Áö ¹æ¹ýÀ» Á¶ÇÕÇÏ¿© »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

¿¹¸¦ µé¸é Áö±Ý ±âº»¼³Á¤À¸·Î ÀúÀåµÇ´Â ÁÖ´ÜÀ§(weekly)´Â ¹Ù²ÙÁö ¾Ê°í
rotate ¹øÈ£¸¸ 52 (1³âÀº 52ÁÖ·Î ±¸¼ºµÇ¾î ÀÖ½À´Ï´Ù.)·Î ¹Ù²Ù¾î 1ÁÖÀÏ ´ÜÀ§·Î 52ÁÖÀÇ ·Î±×¸¦ ¼³Á¤ÇÏ´Â ¹æ¹ý

·Î±× ÀúÀåµÇ´Â Áֱ⸦ monthly·Î ¹Ù²Ù°í
rotate ¹øÈ£´Â 12·Î ¹Ù²Ù¾î 1´Þ ´ÜÀ§·Î 12´Þ ´ÜÀ§ÀÇ ·Î±×¸¦ ÀúÀåÇÏ´Â ¹æ¹ý

·Î±× ÀúÀåµÇ´Â Áֱ⸦ yearly·Î ¹Ù²Ù°í
rotate ¹øÈ£´Â 1·Î ¹Ù²Ù¾î 1³â ´ÜÀ§·Î 1°³ÀÇ ·Î±×·Î ÀúÀåÇÏ´Â ¹æ¹ý

·Î±× ÀúÀåµÇ´Â Áֱ⸦ daily·Î ¹Ù²Ù°í
rotate ¹øÈ£¸¦ 365·Î ¹Ù²Ù¾î 1ÀÏ ´ÜÀ§·Î 365°³ÀÇ ·Î±×¸¦ ÀúÀåÇÏ´Â ¹æ¹ý
µîÀÌ ÀÖ½À´Ï´Ù.

À§ÀÇ ¹æ¹ýÁß ·Î±× ÀúÀåµÇ´Â ´ÜÀ§¸¦ ÁÖ´ÜÀ§(weekly)·Î
rotate ¹øÈ£¸¦ 52·Î ¹Ù²Ù´Â ¹æ¹ýÀº ¾Æ·¡¿Í °°ÀÌ ÇØ´ç ÆÄÀÏÀ» ¼öÁ¤ÇÏ½Ã¸é µË´Ï´Ù.

example)
ÇØ´ç ÀÛ¾÷¿¡ ¾Õ¼­ /etc/logrotate.d/syslog ¿¡¼­ ±âÁ¸ /var/log/secure Ç׸ñÀ» »èÁ¦ ÇÕ´Ï´Ù.
#vi /etc/logrotate.conf ## ÇØ´ç ¼³Á¤Àº secure log ¿¡¸¸ Àû¿ë µË´Ï´Ù.
/var/log/secure {
        monthly   ## ¿ù´ÜÀ§
        create 0600 root root ## 600 Æ۹̼ǰú root À¯Àú root ±×·ìÀ¸·Î »ý¼º
        rotate 12  ## 12°³ÀÇ ·ÎÅ×À̼Ç
}

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

miwit.com sir.co.kr DNS Powered by DNSEver.com DNS Powered by DNSEver.com