砍敺 IT_man 2016-11-3 21:24 蝺刻摩
3 {6 Z# ~. \! [4 O7 J& t
& A0 }# B: `' g. _% a! A3 MCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.6 { C( ~5 f) s9 u" s: K, z3 X, O
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.# k! D9 A" B: x o* L
潭臭敺亙酒erver銴鋆賡靘,摰.; W! W$ A$ p5 a5 s; B% a% U# y- M% C
3 E6 Q. _; r8 Q3 [- ]
0 @& p! Q1 F. s! p6 `! L' O2 z
$ e! w0 R9 A& h* N隞乩隤芣亥蝞∠logrotate雿:
1 l3 u2 g$ l$ u9 j' l7 [1 r% r
- V1 j7 t# T" ^0 B* \4 o. E
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
- h9 E1 w; b; f/var/log/nginx/*.log {
, f# r5 ^7 Z6 D, {4 Q, s4 P; j daily
4 n8 `- ~% `$ g& t missingok 2 z) J/ W! i% u9 E3 a$ c
rotate 52
' }* V7 @9 a* b3 o# e0 q compress : p% q8 [' E' ^+ k2 e& O
delaycompress
; v( }" P, k6 M1 s p( q notifempty
! r/ _3 \" z" j create 640 nginx adm $ o% ~+ n& O2 G8 _" @9 |
sharedscripts
) r8 c7 |$ ?7 j1 C! v+ j postrotate 3 N( H7 K7 D+ H6 Y
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` " K1 q+ J3 B5 i! O! R. `
endscript + d4 V/ E) _# p' R' c$ B* u
} 6 Q0 Q4 G$ [+ ~" ]7 c% V4 j+ K
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. 0 x; l: ^5 U4 l7 U3 m4 m
9 x& Z. z$ [* O, F0 H' E
2 N/ w9 ^& V( G蝵株牧: $ k" q% M5 k7 ^$ v) F9 [* l7 {
daily:亥隞嗆憭拚脰皛曉 * L+ c0 w8 n& L; ^: E! F$ V1 E
missingok:憒曆圈log瑼獢,撠勗蕭仿
( x4 b& W4 N' k' f$ Grotate:靽餈52甈⊥遝亥 ; L- D8 g8 ^% Z9 x/ c$ k
compress:gzip憯蝮株脖誑敺亥 : u8 \: N+ t) m( h
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 ; i2 c* c& j5 Z5 J7 ]8 O" T" W
notifempty憒舐征隞嗥閰,銝頧
J9 H4 [# B/ M T1 V/ {, Ncreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 ) m- i( P% U& H! a
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) 8 @$ `/ X5 D2 w) b
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
1 ^( r7 g* F+ N( p8 V+ h8 H0 M' F- x6 ?1 D0 `+ }; B. {2 K1 e
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: 8 m( a: K$ l, s* i, g
/etc/cron.daily/logrotate
6 M" @# T" H/ ~+ x9 F5 o! ?% @: x- [5 R) x( Z% z" N
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗7 d+ T$ f$ m( k0 |8 _: w8 e
sudo logrotate -vf /etc/logrotate.d/your-conf-file
9 n5 a" e/ \* i$ k+ |7 c2 ?* }+ p C+ S) Y ^+ C2 \! T, B
. M5 o$ V; j0 ]! R$ y
# b# D2 _- V' r, V6 a: |' y閮:7 {7 S' t% @) b7 ^( P
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
8 M U) a* c' z1 b. S' @9 ~9 o! i! f k: V" d
|
|