砍敺 IT_man 2016-11-3 21:24 蝺刻摩
1 u# _7 Q% a" v% P; v% P; ^* ?6 h6 n4 G" k
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮., s( ?% d0 j; k; m9 ?! [
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
) q/ c, ?% e/ D* z( `潭臭敺亙酒erver銴鋆賡靘,摰.
/ u7 Q; y! ~! w" ^; s
; C8 I) z9 K8 v4 u9 O( i0 G
2 G3 k+ F7 A6 R: a/ g+ M+ W
+ }8 V6 P! h0 o. F隞乩隤芣亥蝞∠logrotate雿:# {8 b/ b) q/ H- h* H& r
% p& {+ A, x9 u. J( S6 a
9 k0 f1 m8 }5 A' Q! ^摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
, W- p f5 q* u/var/log/nginx/*.log {
- [; I# o. K% i9 |6 d daily
- |6 t: t y X$ a! C" O8 g2 j O missingok % v' }5 G7 j. N) w3 s
rotate 52 0 l2 o+ @& U, R. k
compress ' b0 E- f# E5 M0 A) f* p
delaycompress
/ r C& J) T9 H7 F- }: W1 I8 a4 C notifempty ; h5 u0 D! L* r% {" l" C! [# R
create 640 nginx adm
w2 S1 w1 f) p sharedscripts & |) X* b, @6 j, D
postrotate 1 g9 w: }8 [6 Y. r: f5 u
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
6 N, ^* \" Q s2 I* f* ~ endscript 4 t3 b9 G ~% z, k1 v$ B- k
}
6 o: `# y" M6 }4 }. ~Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
1 k4 I4 _! {6 T/ N
, |1 o. p6 F, Y; o: u" R- D* O7 V+ G4 V5 A! `" L$ {/ V9 X8 i
蝵株牧: " O% X1 H- a9 y) g3 T3 B9 ~/ a" N
daily:亥隞嗆憭拚脰皛曉 3 U# Z; a2 q9 M9 x. l0 y0 B" R1 j
missingok:憒曆圈log瑼獢,撠勗蕭仿 , O0 A$ V0 ?0 H+ X$ p4 H; Y3 q
rotate:靽餈52甈⊥遝亥 & T1 u+ O" q) b* S0 z
compress:gzip憯蝮株脖誑敺亥 - I E, r7 L7 k/ v1 k
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 ) y) A+ o1 B9 G/ z6 Q9 O6 B2 H
notifempty憒舐征隞嗥閰,銝頧
: T/ J6 T4 G% l; N& lcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
H* x( }, [4 e$ J/ N* a" {sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) 0 i5 |) R8 b- k
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 3 `/ Z8 H y$ D7 [) u! T* Z9 E- M/ y
5 ]& Y6 h. H1 t$ Z% [6 Z! b: ~logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: 9 d/ V2 q" I. a8 V) ^/ E; p9 W
/etc/cron.daily/logrotate- V! w# K! n: f3 ^- ?
$ u. w2 @$ O: x: e& V! E' D; O7 T: v! B$ M
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
, q5 {; K6 e2 u5 V: x5 |2 ^- Jsudo logrotate -vf /etc/logrotate.d/your-conf-file
- G* ~6 u! X7 S" ]# f# H" M- V$ K' m( y Q
" q7 h9 w0 t! L1 n% ]4 U4 j" s
; S2 ]& T1 R1 p: I8 Q+ W9 c/ z閮:3 L/ ]/ q; }: Y, ?) |9 i+ r! c5 ?
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
: V; b* B1 s4 a7 r U9 b! B
. H; |( a! [9 j. S" K7 [ |
|