Logrotate
Linux log๋ฅผ ๊ด๋ฆฌํด์
References: man7.org, network.com, server-talk.tistory.com
What is Logrotate?
Linux server์ log๋ฅผ ๊ด๋ฆฌํ๋๋ก ์ค์ ํ๋ ๊ธฐ๋ฅ
๋ณดํต ๊ธฐ๋ณธ์ ์ผ๋ก ์ค์น๋์ด ์๋ค
์ค์น ํ์ธ
$ rpm -qa | grep logrotate logrotate-3.8.6-17.el7.x86_64
logrotate
๋ log ํ์ผ๋ค์ ์ง์ ํ ์ค์ ์ ๋ง๊ฒ ์๋ฅด๊ณ , ์์ถํ๊ณ , ์ญ์ ํ๋ ๊ฒ์ ๋์ ํด์ค๋ค
How logrotate works
: logrotate๋ cron์ ํตํด ๋์ํ๋๋ฐ, ๊ด๋ จ๋ file๋ค์ ์๋์ ๊ฐ๋ค
/usr/sbin/logrotate
executable logrotate command
/etc/cron.daily/logrotate
logrotate๋ฅผ ๋งค์ผ ์คํํ๋ shell script
logrotate ์์ ๋ด์ญ log
/etc/logrotate.conf
logrotate ์ค์ ํ์ผ
/etc/logrotate.d
logrotate process ์ค์ ํ์ผ
/etc/logroate.conf
์ ํด๋น directory๋ฅผ ํฌํจ์ํค๋๋ก ์ค์ ํจ# RPM packages drop log rotation information into this directory include /etc/logrotate.d
Logrotate ์คํ ์์
crontab
cron.daily
logrotate
logrotate.conf
logrotate.d
logrotate.conf
์๋๋ logrotate.conf
์ ์์์ด๋ค
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
# Log file์ ๊ฐ์๊ฐ 3๊ฐ๊ฐ ๋๋ฉด ์ฒซ๋ฒ์งธ ์์ฑ๋ Logํ์ผ ์ญ์ ํ ์์ฑ
rotate 4
# create new (empty) log files after rotating old ones
# ์๋ก์ด Log file์ ์์ฑ ์ฌ๋ถ - create: ์์ฑo, empty: ์์ฑx
create
# use date as a suffix of the rotated file
# ๋ก๊ทธ ํ์ผ์ ๋ ์ง๋ฅผ ๋ถ์ฌํ๋ option
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
# Log process Rใ
ใ
๋ก
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
Options
rotate [์ซ์] : logํ์ผ์ด 5๊ฐ ์ด์ ๋๋ฉด ์ญ์
ex) rotate 5
maxage [์ซ์] : logํ์ผ์ด 30์ผ ์ด์ ๋๋ฉด ์ญ์
ex) maxage 30
size : ์ง์ ๋ ์ฉ๋๋ณด๋ค ํด ๊ฒฝ์ฐ rotate ์คํ
ex)ใsize +100k
create [๊ถํ] [์ ์ ] [๊ทธ๋ฃน] : rotate ๋๋ ๋ก๊ทธํ์ผ ๊ถํ ์ง์
ex) create 644 root root
notifempty : ๋ก๊ทธ ๋ด์ฉ์ด ์์ผ๋ฉด rotate ํ์ง ์์
ifempty : ๋ก๊ทธ ๋ด์ฉ์ด ์์ด๋ rotate ์งํ
monthly(์ ๋จ์) , weekly(์ฃผ ๋จ์) , daily(์ผ ๋จ์) rotate ์งํ
compress : rotate ๋๋ log file gzip ์์ถ
nocompress : rotate ๋๋ ๋ก๊ทธํ์ผ gzip ์์ถ X
missingok : ๋ก๊ทธ ํ์ผ์ด ๋ฐ๊ฒฌ๋์ง ์์ ๊ฒฝ์ฐ ์๋ฌ์ฒ๋ฆฌ ํ์ง ์์
dateext : ๋ฐฑ์ ํ์ผ์ ์ด๋ฆ์ ๋ ์ง๊ฐ ๋ค์ด๊ฐ๋๋ก ํจ
Last updated
Was this helpful?