砍敺 IT_man 2016-11-3 21:24 蝺刻摩
3 u$ @* n w7 D. G! G% g
# X( i8 t' }) T9 w# y) @CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
5 ?& w& M. ^; a/ |曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
9 y. `9 b8 N4 H. ]潭臭敺亙酒erver銴鋆賡靘,摰.
0 _9 L1 h. X- M s
! ~3 ]1 @& E/ p5 G: ?! t2 V
2 A; S" Y1 i/ A8 x b
# z: \4 M: x7 p. R8 `隞乩隤芣亥蝞∠logrotate雿:
+ }# m6 N' w0 f9 q" Y$ l& f% w* ^( }# R3 @
8 x+ b. r; l- `9 _1 X摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx * a, {2 U4 j. d# e$ j
/var/log/nginx/*.log {
) _1 J) O0 R) z4 B% k daily
9 m& b3 G3 f4 |' y+ r7 ~ missingok ! [' H6 _& m6 w7 X3 a! `3 X
rotate 52 7 p, I/ O% B* Q$ K3 c
compress 8 L! w: Y e8 I7 L: ~, M5 D
delaycompress
0 V$ S! f) n5 [/ q5 _8 e6 c8 l/ z notifempty
- X2 L7 P/ b" b: l create 640 nginx adm
4 X5 R5 f: I/ O2 b# y$ I# ^ i sharedscripts
9 Z- R- z( b% B" H# x' ~2 j postrotate 3 m% T: y0 u9 A* z5 N
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
8 D C4 e2 R" j# P# T! c) t9 K endscript
) S1 z3 A: v z. y6 A) U}
5 }4 r; _; Z4 E" G |Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. . S" r6 A2 h/ E% K8 u+ ?
% `0 i( J5 j6 x+ E U8 F
' [1 v# I- g0 c/ B: d7 M$ q蝵株牧:
: h m( M+ P+ r; b- ^8 rdaily:亥隞嗆憭拚脰皛曉
. q8 s* ]" o kmissingok:憒曆圈log瑼獢,撠勗蕭仿 J6 |; d5 R9 p
rotate:靽餈52甈⊥遝亥
/ \; c- {" Z) q6 a% ~6 j! R. Ecompress:gzip憯蝮株脖誑敺亥 1 w: `6 K1 K. \& ]4 |2 m" ?6 x
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 0 H, ?3 a) P. H% Z* |
notifempty憒舐征隞嗥閰,銝頧 . {+ s: Z. A( t7 j; H- [
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
5 a8 ?# |4 Q- Zsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) $ M/ E3 S! A' q7 _" L$ E
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 ; B/ L$ l; ^8 L% T- n. H- t
( U" V* u( {6 |
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: }; f8 a: W* q6 A; u {# R" q
/etc/cron.daily/logrotate
. X2 w3 t" p: ?# M. t& y! b
, |, \ [& g u8 e4 a" [$ a閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗8 K8 @7 S' O8 Y! c$ B0 w! _/ r' C
sudo logrotate -vf /etc/logrotate.d/your-conf-file
$ s0 B5 r3 x- n! a# H9 h
1 J* ], T" e$ y8 `$ }
8 W+ {9 x5 Y# Y3 P& W
' `) {- ]) Y1 E b" S- j. Q閮:
3 R" a. p2 d! n- }: K# M: X# L: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html* ^4 V1 U+ B W' }/ v; T" V
9 o$ y2 a8 l# s1 T |
|