砍敺 IT_man 2016-11-3 21:24 蝺刻摩 q! b6 d: M' V9 C7 D& V' F
" K5 q! R9 y( s
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.4 X. h& A/ L, U4 ?
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
! ^! }. P J" V4 Q% x. F) q潭臭敺亙酒erver銴鋆賡靘,摰.
- @/ ^0 H+ d; z+ d$ y5 c$ i- @. g7 o- G1 V" r& h* Y
: B+ ]; l$ _7 e" r
( s5 s$ m) P- b3 ]* v+ `9 r0 o: u
隞乩隤芣亥蝞∠logrotate雿:- E+ z' p3 x; A7 c
5 f* \4 q5 B+ s0 ~6 _9 j
3 `& f! G; O" L. u8 }
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
$ o' o7 x0 B( I1 P$ }' w2 ~% m/var/log/nginx/*.log { # j* ~9 ]0 b( G! n5 ` d4 d" x
daily
8 N9 ?# M+ q/ d( T9 v; Z+ \ missingok % |0 O) Z! i: m @" M% ~, z6 J& c
rotate 52
/ ~$ O K) r# J* k compress 6 G3 ]* a: R( m! | ^, b
delaycompress 7 ^: z+ T5 d: D4 `
notifempty
; ^9 J- }1 E2 s6 o6 ^; u create 640 nginx adm
- y8 c/ v' h. ^$ ^* C& E8 K1 A sharedscripts ) _6 M6 u* m# O0 B& c
postrotate : [- x0 g7 n$ ^* `6 U
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
0 z O+ N( o; H- r# X endscript 8 F1 T( _) ?# U% a6 k- m
} 7 [7 r @. L7 b; O0 w& ?- O* q+ P! y; z
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. 6 a% Z% y7 r& u" X7 e: {8 @7 J
9 C/ t# V* g9 w( ^4 a4 y( U8 m* O5 s" y7 h& O J, u# x. g" P, t
蝵株牧: 3 ^2 R6 O$ c: n
daily:亥隞嗆憭拚脰皛曉
" b" i7 V, v" N$ q. e) m& o- y3 Q% jmissingok:憒曆圈log瑼獢,撠勗蕭仿
% i" ^! S! ^' _- Zrotate:靽餈52甈⊥遝亥
+ v" x2 Y' Q4 mcompress:gzip憯蝮株脖誑敺亥 ; k0 z( ] j+ K# R, e9 }7 }
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 8 a9 F! U$ K9 j5 c7 W5 ]! U
notifempty憒舐征隞嗥閰,銝頧 # }$ o0 `* u. d# R2 R
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 $ o4 q3 Y: K& E J& v
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) & m4 s6 |( y. p! r( q. J; U
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 - T. E2 s G6 d, r0 |! p: z3 f
' A# K! v T0 m9 Q- {6 k' a
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
t! K% g1 \& x0 T/ |0 U* F) {/etc/cron.daily/logrotate8 `- b9 L+ ?) V9 m: ?
- g1 e) I& a9 ?
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
6 `$ ]0 G5 a& M6 zsudo logrotate -vf /etc/logrotate.d/your-conf-file
# g, H& T1 ^, X: \! R; J
+ O9 w. r: l6 x8 c9 k3 w5 b
7 X# ^+ r+ v4 M3 V& h; G/ S3 l9 f% t! ^8 k) @1 Y4 u
閮:
/ E$ j/ z" \: \& @1 ^/ ~8 \# B: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
: A4 h0 v1 e: i) ]$ B. i+ P; y* `+ o- J
|
|