砍敺 IT_man 2016-11-3 21:24 蝺刻摩
2 S6 I' H/ ^. u- W5 H9 m5 k9 ]' S' j; A3 R7 `5 a
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
' Q% F1 {0 ?/ K: V' {( [$ ?曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.% M8 H4 y7 E# T0 I6 V
潭臭敺亙酒erver銴鋆賡靘,摰.- z; G1 ~/ D6 V! N
- N. \8 m! v3 Z s. d3 g4 V# G* n0 R0 x# f) ^# z' ]4 t ~3 h
5 E1 y: [% D3 n+ o
隞乩隤芣亥蝞∠logrotate雿:
8 _7 [& s7 I4 \
- W7 R. d ], A* w8 A; K4 K, ?1 d5 C
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
) D8 j! u8 G- I/var/log/nginx/*.log { 9 x: H' w% K, x' d. g0 S, }4 ?! }
daily ; u; @" t# X% l6 K$ R! x& v5 y! M
missingok
( e# @7 ]$ P& b( z1 W# _- P& c$ e+ X rotate 52 % g& e# }! a) p# ]
compress 5 i( o" S3 _$ V) H
delaycompress ( }/ g& a% `# t, ~6 @- N
notifempty ; G, S5 L2 ?+ N6 B
create 640 nginx adm * M% p6 Y" j4 ]$ z/ N
sharedscripts
" f+ u3 r+ e0 h1 h postrotate
2 Q+ R& Z+ [/ F1 X [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 7 f$ n' B% P( z9 E9 P
endscript 2 f% G( u* \ G* z1 k: w
}
d. e$ ]5 `; X4 w# R4 }; |( WLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
, V K+ k# |8 O' w+ R! d Q: \
/ K$ \1 e+ r: M3 T- Z# m- G- ~
, x" w2 X: J7 P7 H( z; ]蝵株牧:
0 p j; v O" i% X) ?! ^daily:亥隞嗆憭拚脰皛曉
5 R$ G9 Y7 `+ E' @ J! b( Z$ amissingok:憒曆圈log瑼獢,撠勗蕭仿
" c4 [; o8 a9 q0 V# Jrotate:靽餈52甈⊥遝亥 0 F- f: M- |7 z2 W: X. G$ L3 U
compress:gzip憯蝮株脖誑敺亥 3 t: C! h* Z8 _9 M# r! _1 a2 c
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
! p/ o" `0 g; h2 Jnotifempty憒舐征隞嗥閰,銝頧
/ x( W* ?9 l. bcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
3 e" d$ L/ L, Z+ ~: G% V# o8 Usharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) ; a( z. r# @0 Q: W
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 6 ?* L& ^) }, r0 B7 P+ i
% @/ s, ~8 O$ B: i! k* @) y. i6 [# [1 [
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
; I3 L* U& m5 V6 x, R7 _% V/etc/cron.daily/logrotate q9 ~ `* J6 l" E
0 {% [. K2 X4 }; \! A; ^0 ]
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗! w' [1 [/ J& Z2 L; I! q8 @
sudo logrotate -vf /etc/logrotate.d/your-conf-file
9 m1 c8 A8 ~6 \7 j4 C* y7 U
1 b1 J* J0 w, U
* @* C/ f3 u: t0 ?5 b, T( `
6 M# J U/ H, o3 V4 U閮:
2 p' S0 e% L7 u: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
2 C2 o j2 F) J( T0 H: \: X/ y$ b7 W2 R) E8 G% ?
|
|