砍敺 IT_man 2016-11-3 21:24 蝺刻摩
" b( d9 J2 n" U5 l4 A0 P* x6 K$ C) ~3 H, m# x- n# V/ G
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
( q7 h4 h, d1 e k3 `曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
' H# h8 l* b) B0 U6 O$ N* \潭臭敺亙酒erver銴鋆賡靘,摰.6 { ~ y( q+ h3 T
) ~$ w" @$ z; w
- J: t# D t& c$ e1 E/ G: q h$ \1 b( {6 E1 t
隞乩隤芣亥蝞∠logrotate雿:
, K( q; \& h" C" P: U
+ k2 b+ h5 I, \5 c } K4 d2 ]4 }5 r. c4 Q0 S' _3 X0 r( ~
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
/ z' t) V, u! J. Q/var/log/nginx/*.log { $ `8 w, @. N5 z3 F# X/ `5 t- X
daily 6 K/ v( ]( u( A/ V1 u
missingok ( k3 T* r7 M3 B7 P. |# G
rotate 52 4 ], V/ O& s6 u0 ^: j
compress 1 P \' }9 x0 |% k; P, i
delaycompress
) |8 k1 }- @9 Y) Q notifempty
; L y: q" U! E- _" k( b create 640 nginx adm 1 T1 Y8 ^% i, P! R6 Q4 X) P e+ `
sharedscripts / Y( F! _6 |0 |
postrotate 2 ^) _$ m J7 {2 d( C
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
3 z+ X$ w2 f1 i3 _; g* P endscript , Q0 Y7 x P6 k; O0 J
}
! X/ R- G/ J8 d" x, b6 j4 t ^Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. / J! g9 K6 F! J$ U0 p+ J F7 |5 O1 x
& H& P! N% ^9 S2 p/ A9 s0 q5 ?6 F; J4 L! ^7 {
蝵株牧: & \. S# U7 Z) J2 F( q# ]
daily:亥隞嗆憭拚脰皛曉 . a1 r0 S# L! c' T# `
missingok:憒曆圈log瑼獢,撠勗蕭仿 / U4 j5 `1 H+ s- }) D& L2 u
rotate:靽餈52甈⊥遝亥
; F' ~* t' s$ B$ h4 g/ P3 y) v! @0 Rcompress:gzip憯蝮株脖誑敺亥
9 C6 d( L/ P. |- a- l6 p; H; ydelaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 ) ~/ e- w1 \9 U' Z
notifempty憒舐征隞嗥閰,銝頧
; p- }) \4 _( Ncreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 : `0 h, n/ h6 X6 T# r% ^
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) 3 G4 `: N" l6 Z- a9 W5 M8 X
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 % _5 \" |+ u7 v2 w. e) T7 B: G, A
t$ H' v; o, U+ ]7 M6 a/ S+ tlogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: $ t% X1 g9 z! }5 A! ~
/etc/cron.daily/logrotate
' @ g y+ {2 L) J) ]3 F; w4 C
% ?# {6 D* l1 \: _8 d. A" v閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗: E; p/ G( Z3 w
sudo logrotate -vf /etc/logrotate.d/your-conf-file/ t+ i, @; C7 |3 i0 B: _
& S5 h1 Z1 w: q6 O7 D' h' w3 G
0 Y8 o3 R; E7 {2 D+ A+ l5 T2 U% L1 D' ?+ P+ N" P7 l
閮:
4 U. L- x9 E, y7 s% t/ I) F( C: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html$ C# N0 n9 ~/ W, U
9 P: P' L6 E& r8 P$ u2 `- C' e- R
|
|