砍敺 IT_man 2016-11-3 21:24 蝺刻摩 9 F7 b5 V' Y' Q8 U1 u
1 V& ^$ g3 L" Q5 aCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.7 K+ y9 A. r3 M8 w7 ^1 { o
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
. k2 R- E- L& @9 V8 M# z潭臭敺亙酒erver銴鋆賡靘,摰.% C* y! {) Q7 X9 D3 [$ L# V$ v
N5 k1 W9 w1 l# N# {8 ^2 R4 e! y/ U3 O6 Z# C: Q5 Y5 V
# i4 w. i, R' b' ?3 H6 ]
隞乩隤芣亥蝞∠logrotate雿:( j H, c% m/ w$ h! C5 y& ]' `
1 k6 h; Z$ p% S# A7 s" f% M8 r
' a2 O$ |& R& x5 }3 k* B: K摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
1 G4 T# h8 B' F/var/log/nginx/*.log {
8 B1 y/ I) @/ K2 A! m7 V daily / r/ v$ p* K, a$ ~' ^: I
missingok # |+ @% ?3 @. L
rotate 52
3 z7 g, G \5 ~* \8 m4 F: ` compress : W6 ]$ _/ A; L" g5 I4 k
delaycompress
8 X% s" |! V! N! z2 x% @. F notifempty
$ {. A8 M1 n: b% ~ create 640 nginx adm
2 I! p, d: y4 ? sharedscripts . J [/ |. S( B. b# I/ F
postrotate
x% i! A. d& `3 D8 i% w9 E/ ?& Q: _ [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` # h3 ^( X/ Y' V
endscript
1 G* ~7 c. P% T}
2 W7 l. J6 Q/ zLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. & k' C' T$ s$ I: \- E# N- ~
6 { w! j0 G: P" \8 W, B" ]
F# ?# Y! G6 q4 I# N% d# l0 i3 _/ `蝵株牧: 9 S3 a4 J% m) v9 S/ G
daily:亥隞嗆憭拚脰皛曉 T3 t4 n: g! K# v/ L
missingok:憒曆圈log瑼獢,撠勗蕭仿
1 W2 ]( P( f- b0 \0 ^! F2 W# @rotate:靽餈52甈⊥遝亥 - O5 @* L9 k9 R, t" m# h+ b/ r
compress:gzip憯蝮株脖誑敺亥 " A5 m6 A f% V' e
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
, c: i! @- d% i" [; Knotifempty憒舐征隞嗥閰,銝頧 2 B5 k6 }0 q" P5 A9 @
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 ' H" }( V; I" v( v; v3 ~6 _
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
$ j; t" Q: q: K; ?- dpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 7 l# c) B5 M v6 B' g: O
+ Y. g5 s, N# ]
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
5 E: u! a; a" o# a, R1 L/etc/cron.daily/logrotate* w6 u+ p* c# Q, x
: ]6 y5 b4 f R7 k+ u
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
. H! }. ~# C" h3 isudo logrotate -vf /etc/logrotate.d/your-conf-file- ~1 J& y2 {7 B9 [0 @* K
$ k/ Q; ?# y; q4 @. |
. m/ C! O7 N( S! t
& e/ r" Y' S1 g閮:
9 Z1 t; Q& X. T" z$ ]: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
8 ~7 q2 |) I' a' M
0 A4 @ R" j1 ~5 |2 e* z& V) z |
|