砍敺 IT_man 2016-11-3 21:24 蝺刻摩
% l! ~! ~1 r7 S5 T
' j0 g) L. f I4 Q6 fCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
: E8 ]% q! {% w" q% n- B曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.: o% ~0 L6 X2 Z* F7 {6 F
潭臭敺亙酒erver銴鋆賡靘,摰.0 k' r, y5 R: c
. _# p% ]- ]5 e; C2 h4 I$ l0 d. y
9 b& t, E. o+ o4 W
! O( Z# ]9 R, P. e隞乩隤芣亥蝞∠logrotate雿:
# }: b7 \ `7 W) a5 w% j7 d) ?, E9 M' a1 N# p- Q- A2 B8 W1 f
2 g) H _6 @3 \% V0 W摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx ' |+ `- ]8 P; M. D9 [7 f
/var/log/nginx/*.log {
# S* T* T6 }3 O" C& b; D$ h7 v daily
+ |( j) u& x8 X% U7 T* r$ r& U8 B missingok
- f: j& E4 E/ H rotate 52 ' l' q3 [* x) J- c0 a- E( u
compress 4 ]! y9 ^+ J7 M8 M
delaycompress
$ f6 V4 @0 l. N ~, `! ] notifempty
9 K4 u0 c* x" T' l1 A- n; c ] create 640 nginx adm
3 [5 u8 v4 E. R sharedscripts
9 A/ Y& F( ]. Q postrotate
4 q" R, |5 [8 i% R. Y( O( Q [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` . w' W* n3 o; i( z
endscript
' I9 L& i0 S/ r( }2 x, [3 x}
( l; Q f C T) z$ f7 ILinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
) F! ~6 B. w: ?- s' a0 Y }3 t. L: M( P& D; s; W
) H& e, @ ~* z8 t
蝵株牧: ' o. n! J' X l2 B: z+ V1 t
daily:亥隞嗆憭拚脰皛曉
( Y+ Y' W- M/ x) J" W4 {0 ]- imissingok:憒曆圈log瑼獢,撠勗蕭仿 , b1 e$ w/ R5 T6 l# b, \
rotate:靽餈52甈⊥遝亥 / q8 o) m0 R+ M, q. N# F
compress:gzip憯蝮株脖誑敺亥 $ x& y8 { y' t& S
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
# t8 g4 W% C" ?3 }# Z3 w; A# l5 anotifempty憒舐征隞嗥閰,銝頧 ; s' a$ g/ J" O
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
& Q) r, {$ e9 w, ]sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
/ X; i x. m2 J4 Y& t! M$ g3 Npostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
7 M8 L! R" Z; \& i$ C- _
& q6 h9 ?4 V6 Klogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
8 `7 {& S5 A" J! |1 N; R+ R( H/etc/cron.daily/logrotate
+ y _2 ^, ]/ i! F
4 G# p+ T! s% D2 t# H; v& F: I閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
; Y3 h/ s/ K0 l$ A6 Usudo logrotate -vf /etc/logrotate.d/your-conf-file$ Y9 D( Y; C2 Y
! o! n3 R# X5 n( p# [ v1 A/ `3 b' l5 [9 m! ~, C" U
7 J: S$ R C# A8 r; a1 j
閮:
6 {+ g) C/ O* }( b3 p# v: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html- P& P3 `7 ~- Z# @% }" L& [" J+ _
7 ^' l/ v1 m# E: i
|
|