砍敺 IT_man 2016-11-3 21:24 蝺刻摩
2 C! ~& r7 r$ j6 M, T9 b3 ~# \3 L
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
9 G, \- |3 }" x+ @曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅. A& O8 _ m! i, w& ~; p4 Y$ x
潭臭敺亙酒erver銴鋆賡靘,摰.; J' g' N% ^0 [: F) \
0 i$ z) s' I0 \# y6 }
$ n0 V u9 X% }* C3 k
6 V# D0 O9 q! S+ L I) D# l
隞乩隤芣亥蝞∠logrotate雿:3 E6 K8 a% I% k9 y/ Q0 v
) J" q6 ^+ U4 E b
! d' |0 E Z/ r
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
- J, u) U8 m5 ~* Q. V& I4 n& s* H/var/log/nginx/*.log { 7 B* x% Y$ l5 t# Y/ I6 `) W, R$ q3 A
daily
. C: ?7 F; P' c0 Y6 u missingok
2 A! A: p6 v9 L rotate 52
1 ]1 a) z8 K* S( Y5 m compress
9 w! T$ L4 ~( X delaycompress
# [% V$ V. b' Z$ `$ e# L# O notifempty ; D1 ~" Q8 }; E3 T1 t: C
create 640 nginx adm
( F& ?# `5 y0 W. \- y0 H2 D7 R sharedscripts 3 F5 @6 V% O: S8 g) [) j
postrotate 7 i3 i) M3 I: H3 b6 y
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 0 S) P4 b5 Y. |9 @5 y3 L
endscript
: c& s6 h9 T. x' M/ s1 f+ h ^} 0 k( x0 L4 X, V8 A q B$ i5 m* }
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. ( j ~- e! V _! h3 s
! X+ h) h1 W! z# D4 l9 }: w
j, w3 a( C: k. s' g蝵株牧: 1 f4 |- X* S Y
daily:亥隞嗆憭拚脰皛曉
# @) W7 r; A, w+ F) R" Lmissingok:憒曆圈log瑼獢,撠勗蕭仿 # |* I' @9 |' j2 t! ~3 T
rotate:靽餈52甈⊥遝亥
0 S9 @9 q5 X% |; ]1 R2 ]. I. h @compress:gzip憯蝮株脖誑敺亥 4 u4 @6 E& @1 R7 B
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 8 Z5 g. Q7 ]7 ~2 |; _/ ~4 i$ L
notifempty憒舐征隞嗥閰,銝頧
* G* C7 t: w3 B$ Z. t R0 ?create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
: T$ r9 e+ L/ _0 O' a( wsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
/ K R7 j! E( l& U" [ t+ Qpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 1 K5 D O8 f8 s' E L8 a: @2 I
6 S+ ? Z& g$ vlogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
" W7 `& x6 Z* V) I( J/etc/cron.daily/logrotate
2 L [2 p+ F3 F8 ^ a6 b- c2 s; a& [1 g
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
& Z. t- V& ~# L4 K$ s, h: Psudo logrotate -vf /etc/logrotate.d/your-conf-file& ]8 u3 r5 F) ~
$ f# ?' G& l5 I
# j1 p5 @( ~( d" \- F* r. n6 V6 J' Y9 K+ X) _
閮:
* l: j/ N. |' y/ j6 [8 Y: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html. K2 M7 M' C- t
, m/ j2 D4 k) b1 m) ?( ~& r |
|