砍敺 IT_man 2016-11-3 21:24 蝺刻摩
( O! ^4 n! G2 `1 @( j. M% J3 G7 y2 l% E) }
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.1 L$ d2 B. c* e1 \
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
4 k& x) b6 B0 P" d* Z# S1 t& Y潭臭敺亙酒erver銴鋆賡靘,摰.( L% P) n- b; r: d+ V3 W
3 C) ^( `- T5 Q5 r; S0 x
2 b' U/ l4 c4 ^
' P$ ?2 [: i/ W5 f, I. Z4 j0 W隞乩隤芣亥蝞∠logrotate雿:
7 E! J6 \1 H1 C# f' L9 _( w7 ]& A# N( E; E4 h( E
+ i* n* C7 q/ O8 t, y, `9 \摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
. M# ?! J& O$ `+ ]% L/var/log/nginx/*.log { $ W8 C9 t, B5 Y0 P
daily 0 K5 G" F! Z5 _- K7 z5 r
missingok
$ w& E2 z; ~. a M* T3 J( K rotate 52 E8 Y, H" ~; d+ j1 X
compress ) E: r* ^& z: K* ^; T, g
delaycompress
. ^& u( L8 {8 Z& ?2 [, E notifempty
. q8 U% P( n5 \( y; e create 640 nginx adm ) [- n! m$ W* i
sharedscripts
, h" E( l4 H6 O. \ w7 L postrotate ! @! Z+ d8 a t1 {! I$ H5 D6 Q- Q: l2 T' ^
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` - G3 d: K9 Z2 k- Z! r2 p
endscript
- W: e: ^* K/ P% S& T/ {& V* U}
: U; e' r# l" ~4 iLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. ( d( Q+ w, W% N" Q( T) w
" j U. j5 n# [* h7 U7 `" O
9 m% F3 l; X# O7 W- k+ t蝵株牧: / Z4 V7 D. W1 C6 `2 s. b
daily:亥隞嗆憭拚脰皛曉
0 z- K' o p+ M1 r* g2 g8 Omissingok:憒曆圈log瑼獢,撠勗蕭仿
( s0 W* z# m0 Q& A# grotate:靽餈52甈⊥遝亥 ! P5 d( d& t$ e3 D: \- s
compress:gzip憯蝮株脖誑敺亥
& ~4 [% r9 w3 e% w3 k; j# Fdelaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
( E3 I. ?' J$ l: b! @notifempty憒舐征隞嗥閰,銝頧
! H* g. O# e% i6 }$ r0 K0 ?1 Ucreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
- j( e, g/ f9 l& J( R; esharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
2 i' |- n( @ P. W, e4 O+ j3 Spostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 0 c- Q, @9 N, ^1 k
|- x, C2 K6 P
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
0 L" I0 }. ^$ T& p% o8 H/etc/cron.daily/logrotate
& _$ h6 b3 J! e2 e1 i2 R8 R1 Y: G2 w( Q" ]0 A2 @: v. P& V
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗" a7 a+ b) l! u
sudo logrotate -vf /etc/logrotate.d/your-conf-file
5 d' }( S) p; ?; t, f% C& w( N; v9 u* c; Z) A
+ v- l, x; C! f; W8 g. k
b7 S# q4 h: Y. @* J閮:7 B" m1 E' w9 g/ R, i
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html8 N3 w0 U/ A; Q& D- U4 t
$ J& O- s+ V K- Y% N |
|