砍敺 IT_man 2016-11-3 21:24 蝺刻摩
/ H1 {2 }1 W$ m0 L. }
0 r h/ E/ W! s! l+ U$ gCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
6 @0 a. s: A; w5 O4 h3 K8 I. G曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
9 t. w' D" E+ I% h潭臭敺亙酒erver銴鋆賡靘,摰.+ u. S, x/ o: G% w& E7 X
/ @# A! X' B. R' j
$ y, _ }! O# i) g
. ~! ]5 g Q3 v+ y, d! p隞乩隤芣亥蝞∠logrotate雿:
$ X9 ~: W. C# e' {. E* t4 T2 s: Z7 Z9 k3 D; h! o8 V: h
# Y& i5 k8 _ {8 H$ `8 z. F摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx 2 x3 P+ M8 `% H# @$ E* | ?7 K
/var/log/nginx/*.log { : t( ~) }! o. R) g- _# F# ~
daily : ^6 _/ I: h: Z8 ]8 [- l
missingok 7 L6 D# b( L: p5 e+ G! r8 C
rotate 52 5 g' T1 [7 @9 ?4 R0 b
compress * o9 H, Q ?- ?- \, |# R
delaycompress % c' K+ R% p# j8 G9 j& S" u$ J1 m
notifempty + P+ H* z8 l; w2 C0 A0 D
create 640 nginx adm ( d1 R& Q, i& q! A' |
sharedscripts 3 Y0 T. |: S1 Q3 k1 b5 z P8 p
postrotate
7 `; h: {2 {7 u. h" [( ~ [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 4 n$ J* `+ i' a( i% m
endscript
( d) _$ q9 u4 y/ K# a}
6 W& v' J3 P" I! o! c0 J' x) VLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
3 i; Y4 U) T A: Q/ [2 A
0 o* d7 w8 v1 `( e4 L( u
! u: N2 R- B1 @1 X+ n6 G蝵株牧:
# B; y2 u3 V5 L$ Y1 t; f2 tdaily:亥隞嗆憭拚脰皛曉 3 K, C o' ?# B
missingok:憒曆圈log瑼獢,撠勗蕭仿 1 j8 [! g4 {* M5 i0 z
rotate:靽餈52甈⊥遝亥 & o7 Z: J2 r) G/ Z5 q# x
compress:gzip憯蝮株脖誑敺亥 ) F: ]( q# s1 A) r4 }
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 / R+ B$ c" t6 O& N- b9 b& D2 j& W
notifempty憒舐征隞嗥閰,銝頧
# T7 ]7 [- Q5 F% X7 R/ Zcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 / V- g7 s/ O: x) Q$ @! ]
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
9 |/ Y( v7 O2 e0 C- D' W8 l) d: H, K' xpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 " t1 X8 y! j$ B
& r6 k6 e" S# j! Y
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: - i3 q3 Z& f1 s$ I/ h0 m- m/ y. ~
/etc/cron.daily/logrotate: T8 \1 N! b2 L! T. |/ G$ b
: a2 K; c% ?( Y- M- W ^7 b閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
$ W0 |: B$ ^* y9 r osudo logrotate -vf /etc/logrotate.d/your-conf-file
7 i: N+ `) U9 h5 |0 ]1 ?6 c! Q, j2 i* K1 q( W4 a% p0 A
( E* Z0 X5 ?3 p" V! A X I* M& t3 K$ I! D3 E- P$ b
閮: Z" ~' n) u$ ^1 q- w1 |
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
{3 j( m3 u, |* S
4 r: f1 M; H7 c3 Y |
|