砍敺 IT_man 2016-11-3 21:24 蝺刻摩 5 R, ?' W1 K! r/ s. Z
; N# j+ K' A# A6 I. P$ H7 z2 `: `
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.: m; f* g9 ~& c# r% g) t
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅./ N% q/ L6 a1 I% v; z( S; m6 i( l
潭臭敺亙酒erver銴鋆賡靘,摰.) u. Z" H* Q' x$ [$ R4 C3 s
- \* P! N# A8 _1 b/ h8 T4 O
- w0 |/ x3 X* H2 e1 q: e* d
7 H) b# C% E' d' _隞乩隤芣亥蝞∠logrotate雿:
( X: x7 y; D9 |- d7 T r% k( X* _0 {& j6 a
m( L* R: F, L t
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx * r7 Q# u; [3 x9 _6 \7 R: b2 [+ G
/var/log/nginx/*.log { , c/ ^& K# n! Y
daily
; f$ m1 T! m j3 z: y missingok 6 ^ ?' b) E' |# ~6 W$ J
rotate 52 0 z2 k8 ]) `- V3 Y" m5 k; m
compress
8 _; L4 H! P* @. v# u) w delaycompress 9 b* L& ^+ |1 p
notifempty ( ~/ |! y! ~; T3 c }5 N) u/ {
create 640 nginx adm : u5 G8 _% w6 p
sharedscripts
- m* K/ g6 p7 Q( B1 r postrotate - N. P1 F/ ^2 ~" @" R5 o3 `% h: A9 H
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
/ ]+ C/ X, m1 l, {+ [. R endscript 1 o" e6 v4 D7 E% I( v% X+ H2 R( ^
}
6 s: S& j- w" p7 R1 c6 b) C$ X8 mLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. " h- y2 r- c' l# X. V0 [
% O' I2 q% Q/ e( B9 l
# _$ s, ~. d1 O$ {
蝵株牧:
* I: S0 X4 u; Sdaily:亥隞嗆憭拚脰皛曉
. p5 Y! B7 C e1 y3 ?8 l- S. nmissingok:憒曆圈log瑼獢,撠勗蕭仿
! D D% T: O. s/ hrotate:靽餈52甈⊥遝亥
! \$ n: K$ R" _8 U' rcompress:gzip憯蝮株脖誑敺亥 9 L3 K( z% ^( c9 K
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 : W! g' c& G/ n0 g' u" G
notifempty憒舐征隞嗥閰,銝頧
5 S' H& ~6 h+ L5 j* y: q7 _5 k) V! Hcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
3 h" Y2 w! Y8 M1 j: R% K3 q$ ?& ]sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
3 L# {: N- w7 bpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 ! j; c7 M3 W& L! s2 |( [+ I* c
: f& X1 ^7 M0 Z. O+ [2 E
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: 4 ]4 Q0 _% s7 P/ C6 h
/etc/cron.daily/logrotate
) f: n5 i- \1 ^2 ]6 ]0 T$ g/ }
! E2 W/ X% `; Z% x* E閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
3 H& w. t4 b- rsudo logrotate -vf /etc/logrotate.d/your-conf-file
3 T l, P% G7 t3 Q9 r% T' |) j
; q+ @. Q/ ^1 C3 U0 P7 a1 M' _ E% z* F0 }7 }
8 Y' H! O0 X0 ^& w' {; r4 F8 ^5 t `
閮:9 A/ h& k' I) _% W4 Y' B r
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
4 F& _+ ?- b. \: K' ~# {) E: v; B& X
- e' E: a$ B0 i/ c |
|