砍敺 IT_man 2016-11-3 21:24 蝺刻摩
1 E) T; t% B' c2 T& C* f& @6 V3 ^! m6 v: d1 s! i
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
9 A# Z+ d$ B* T! R/ ?: [曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.+ Y6 G) c, e1 N" w _ a% y. _
潭臭敺亙酒erver銴鋆賡靘,摰.# Y9 K8 w3 N$ {+ t: v# B
* P3 ?. a, d3 B* C
1 q$ p9 J/ U, f1 K! d3 o8 _) q' Z; n
- I9 s3 ]9 b2 e5 l/ x! v隞乩隤芣亥蝞∠logrotate雿:
9 X7 P' o1 J) i* a- H* ~0 |) e6 M. B
, O, n. M( m% J' _6 m% O- [+ \8 J摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
) Z8 v; U7 n0 p3 ]/var/log/nginx/*.log { - H- c, p9 b4 S* e
daily * p7 W- q& o2 v9 a, @$ ?5 X8 L% N
missingok
v& Z" C8 _- A3 s+ d1 I N rotate 52 & L" R6 |9 ?: _5 c/ h; X
compress 4 E9 t) Q* w B; m/ W( S b
delaycompress
6 }8 i" M5 l4 n* z notifempty
, U4 ]; Y* m' b- I) E/ w J- v0 s create 640 nginx adm ) W; w4 ~, [- P0 T. X
sharedscripts
- _3 u) N- g) V; c0 O* ^7 p postrotate 2 `3 V7 w2 S; I- N( W5 q' g
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` & h+ {- o. K/ d0 K
endscript / W( a; K; R5 ` F, R: z
} 9 W7 ]- i* p& l) `' u( D
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
- h, a) \2 ~9 i9 v$ c; j+ X: e# |0 o0 Z. T6 Q: {- W
2 U7 k0 B# r* F7 R9 l% N蝵株牧:
0 K, }3 A5 J0 |( j& Y& kdaily:亥隞嗆憭拚脰皛曉
5 ]+ d, a, h% t+ F" f- mmissingok:憒曆圈log瑼獢,撠勗蕭仿
$ l. j$ |. N, t" Y& Mrotate:靽餈52甈⊥遝亥
8 ]( v6 ^/ w6 o" B6 j5 g6 ccompress:gzip憯蝮株脖誑敺亥
: \/ j3 w1 f+ {. J8 Gdelaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
+ m% ^# ^9 N1 ~8 ]) s8 [2 g- v% w3 `notifempty憒舐征隞嗥閰,銝頧 3 W( Y4 }3 ?5 D1 w: E- h/ M
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
0 h: V1 x/ c. ?sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
M; f+ t" S7 g& ~0 h: Y$ Xpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
0 w& }3 y- A. K7 p9 E% H% }8 F- N* s) C
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: / p! r8 i" K" Y+ X3 n2 f
/etc/cron.daily/logrotate9 r7 f. T: G5 `- i( [$ C
9 S! v V! K$ x) Z5 h- l9 X' t
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
; X. t0 w7 P* ?5 x/ J( K. isudo logrotate -vf /etc/logrotate.d/your-conf-file
; k) M4 z4 p0 X) ^) ^9 f) a6 \, C6 F+ m
& d$ L: A- j6 q
4 E& n# D4 k$ w
閮:
) J+ `' L+ ^* ?: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html: Z, G' n3 ]; K
4 W1 ^# Y8 |9 z4 S5 l' D
|
|