砍敺 IT_man 2016-11-3 21:24 蝺刻摩
( x, t& e% k+ V0 F" A! {0 f: z5 Y3 }# u, g; Q" k, S% d
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.2 v0 l2 `, T, O1 u
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.1 w0 M) P* ^1 e6 E0 T! H$ X; A
潭臭敺亙酒erver銴鋆賡靘,摰., V$ E9 K1 W K- W0 I1 f9 g
2 S* }' s8 J7 w/ j+ [
2 K1 w S k) Y/ l$ G
# |/ O9 H+ h% @. t
隞乩隤芣亥蝞∠logrotate雿:! P9 J9 Y. y N" h: L- F9 l$ W
4 E! ^) P- j3 s, R8 C! I& }9 W
/ V3 D7 f5 g. F% y7 r6 N* k摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx 3 G c. y9 Q$ Y4 A& u
/var/log/nginx/*.log {
& b+ ?8 F9 [: P8 E9 G3 H daily : }+ j* |9 \$ z- d Z
missingok
! a; o0 F1 Q6 D8 p# w rotate 52
: l* L, \1 s, D8 A. D% ^6 }; P8 i compress
( f: |: }- ?0 R delaycompress 0 m7 T( d7 J. W7 |+ H2 Y, ~
notifempty " f& c* k T7 W. z
create 640 nginx adm , Y! W) u' |; [( H% I* m
sharedscripts
! s. W4 c, P' c postrotate 4 b8 B) x' v, D! P- x
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
% K3 D* m# r# g1 u. g endscript , b4 X! s& M" R/ H6 l/ A/ c8 b
} ' ~% S% B' N1 }+ S( ~& _
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. 1 Y1 a2 p5 |) A
4 x% Z: a# |2 p; l$ i, r
! }$ G" `9 e" A1 N, K
蝵株牧:
7 Z# Z4 y3 d* T3 r: S$ |daily:亥隞嗆憭拚脰皛曉 % y5 q$ }) y5 Y4 X- y8 Z; d
missingok:憒曆圈log瑼獢,撠勗蕭仿
( L, Q2 ~5 ]: v; V& |rotate:靽餈52甈⊥遝亥 ; r. c; d& [) f' [; `+ r
compress:gzip憯蝮株脖誑敺亥 9 l5 `: u- D* K1 V, ]0 t
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 5 l: B7 g/ u3 F
notifempty憒舐征隞嗥閰,銝頧 8 ~) ^: C! E/ P$ `1 I
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
* Z- N! y$ o4 a& J2 x5 Gsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
5 B2 R( M4 u3 W/ ppostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
# d0 L, F+ z# t8 ~' c% n3 w" l$ {/ Y% A. S! l
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
( Q& ]6 b4 y l/ n! Y/etc/cron.daily/logrotate, G! F$ ~9 `" P6 n
* k& a) {" ^; U1 V& z0 s
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
+ j5 @3 x' Q" e; Z1 p0 [! f9 f( _$ osudo logrotate -vf /etc/logrotate.d/your-conf-file
6 V" z, z/ L8 l/ W% ]+ U9 c* x8 ?2 X5 S6 i5 R5 W9 Z
8 ]- i, ~5 h/ w. H, b; a* v2 G5 W6 I+ d, @+ Q
閮:
& S( l8 _4 E0 l% z: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
8 e2 w2 F' |5 A- m" n& T( \! X& q- S0 a
|
|