砍敺 IT_man 2016-11-3 21:24 蝺刻摩 9 k. G/ j* X1 J: C
8 ~* Z1 X& o- y3 o
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.) b1 w! y' ^# _3 g) G: n% ?
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
0 X4 V# t) z' a+ V7 P5 R, K潭臭敺亙酒erver銴鋆賡靘,摰. W8 y. f& V0 o! t/ c: n. @' Z% t
. ?, a$ t+ [; p/ c' U$ C: R2 R2 O
6 \$ n, W: Y7 D5 x' b隞乩隤芣亥蝞∠logrotate雿:4 o# A) j6 ~' a7 S
. s! c7 T9 L, ^, r3 \3 g) _5 p
) V; ?5 p2 J2 [+ o x- ~9 l% T0 l
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
' V3 X+ S& d* p/var/log/nginx/*.log {
) b' v3 e4 S, D% Z: f, c daily
# M1 F4 {% P: k3 n missingok
* h6 ?5 h7 b2 F8 H- J rotate 52
/ e' H3 U9 _) u8 u$ S# i, y- q compress ' P$ K% A: P( G: J3 l/ i
delaycompress
/ L, [/ t! L, y# u: N" P% c notifempty
4 W& p% x1 l6 Z' v9 [5 ]# | create 640 nginx adm 3 i6 f# ^) N* C9 H
sharedscripts ; L& I' N0 m, F! y5 d
postrotate % y2 a- p$ p7 V$ Y6 V* i
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 6 P/ t- P! f8 r! l
endscript / c$ F8 X k5 t
}
# h7 A* H# ?$ s9 g. O1 d% P% ULinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
$ W, Q% h" a6 b% Z: s' G1 ^. y; C9 q) X# O8 l* X# k' c$ H4 O
% V$ F! w; e3 {# F) F8 l; q, E蝵株牧:
H6 y0 |, _$ J8 k# k ydaily:亥隞嗆憭拚脰皛曉 F/ _1 N: h4 C$ F) F; \/ ^. J# O
missingok:憒曆圈log瑼獢,撠勗蕭仿 0 ]) Q0 f2 O A' L) L
rotate:靽餈52甈⊥遝亥 ( p1 k1 P! l8 `6 Y
compress:gzip憯蝮株脖誑敺亥
$ d" P2 x0 C3 D5 t$ U- s8 }6 Gdelaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 8 j5 E7 b' D% L3 V V, o* p! F
notifempty憒舐征隞嗥閰,銝頧
6 M( p9 e- f2 `1 hcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 $ S8 Z: Z# w+ z) D3 |
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) % t, R% X3 u. ?& B& B: \+ w- s
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
# L8 u" V+ ~$ a* C
9 ~8 ^$ F/ q E3 \- W7 e/ B! plogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: , a5 U2 l9 e5 Q6 ~ L7 ^3 n5 @
/etc/cron.daily/logrotate
! |) x7 z) }$ T2 Q Y9 N+ L, ^, n1 |1 {: {! w/ D
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗2 g _( b2 t* I6 s
sudo logrotate -vf /etc/logrotate.d/your-conf-file2 U$ e/ M$ ^4 I- a" D
: X3 @3 e; `/ H. L: o* }7 r
8 Z! y2 F- W% R; A& a( |- ~* O7 Q; v c# ]* ?- h
閮:
e1 \: a" [. T6 D6 ]: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html, K$ e" y% ]4 @2 k( T. C# I5 w
) i% s4 E3 r) n- p: I* v! \ |
|