砍敺 IT_man 2016-11-3 21:24 蝺刻摩 8 z1 n/ X& d u/ m' B+ ^' @( L& ]- `
- D4 a$ M* {/ g1 v9 m* p/ ICentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
$ j- q ^% c8 h$ x6 T曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
/ T9 ?8 N6 ?( r+ d+ ~3 T7 c T潭臭敺亙酒erver銴鋆賡靘,摰.
# z m, J x" M0 b' L" L" B3 N& |) F- A1 D
N t' S7 @2 ^: U/ L* h+ u
* a |) D" {* c) D4 i
隞乩隤芣亥蝞∠logrotate雿:
" h* U+ E/ @9 g7 D7 i1 U- p% F+ }6 j
! w3 G$ e5 x* n7 l% y
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx ( {* `; i3 b6 x
/var/log/nginx/*.log {
/ V) k y7 ]5 D9 h2 g; d; k$ `3 M) z" F daily
* i' B& o' S& q- f, Z) b missingok
5 ^. m; f; Q( {) Z$ g0 S3 K rotate 52
L7 e* C) Y* G% w0 h compress 6 z) L3 o5 f! Y& y( d
delaycompress ( O; {( V4 M( i8 h4 x: R
notifempty
" f) g0 N4 N$ h6 _7 Z create 640 nginx adm
8 h! P) o2 `6 g sharedscripts $ ^, f) D1 I! V. I9 n1 L7 b$ z _
postrotate ( V- U. C* Q1 K g
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 9 z8 l. o8 u1 r Y* Y/ Z% s
endscript
7 \8 A# s' [7 p# a6 \& x}
, H }$ }* n$ W0 M% ^' j5 e6 VLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
i& o1 l9 [+ {6 p0 b
7 G+ v2 D9 i# p) j- x( A
# x$ ^3 u6 ^6 a6 y2 k# g: z蝵株牧:
4 ^8 [, {. U8 j: m7 h8 {4 x+ tdaily:亥隞嗆憭拚脰皛曉 8 T2 R% Y( p) m6 F
missingok:憒曆圈log瑼獢,撠勗蕭仿 ) J, J4 {" s6 ]9 e4 B3 u6 u
rotate:靽餈52甈⊥遝亥 ( X) A/ N7 b- q" \
compress:gzip憯蝮株脖誑敺亥 2 P) G" T9 p1 ^2 z T
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 . l3 a) p2 n; ]; W
notifempty憒舐征隞嗥閰,銝頧
! V# r' ~% F R: u& ]create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
2 f5 B$ g1 l9 ^9 X& u! |" j8 xsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) 7 \, E' H; O/ b, a2 X
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
5 L" |! y3 j& L V& B
' i$ G% c5 N. j3 \1 Blogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: ' X# L, @2 N+ m, ^. y
/etc/cron.daily/logrotate9 J( e6 o# q# O; O' m" w
6 c9 [% C; g! J9 \
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
1 a2 x4 P' e/ m, T( Z; }# H: T bsudo logrotate -vf /etc/logrotate.d/your-conf-file
) ~# Q1 h% k6 Q) a3 }/ @9 i- q4 a+ s
7 S+ f# |! R. C
; h9 s8 _! {5 k, _" ^* M; b. A閮:$ y0 j' Q$ |; t2 Y! p
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
& C( x( r* o* A0 V; H
2 ?" P8 i6 s6 G* N3 c |
|