砍敺 IT_man 2016-11-3 21:24 蝺刻摩 9 z2 `$ |" f" r+ r- {+ ~
' u: \3 W+ r, b% kCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
: L1 }4 Q$ T! l1 V% Z j曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
8 E! \. y! ?$ D% S9 C3 L% b; y潭臭敺亙酒erver銴鋆賡靘,摰.
: V" ?! X8 L) ~ f& B( F
) y% ?" |) R& u1 R3 T7 c6 O
$ y2 E# I# i+ J+ L. p5 j. @
, z i& j9 A+ m2 I2 S8 A$ x隞乩隤芣亥蝞∠logrotate雿:+ m7 |6 d2 e3 i* j$ ^. Q4 M8 F
9 b. s, e1 M) a. v9 l5 R
* s- D$ X: F$ [6 a/ u r! c7 e摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx 7 ?5 t. s$ o- g9 e9 d
/var/log/nginx/*.log {
) `1 }7 z0 h1 b! @, i/ b. f+ c9 R7 l daily
3 Y; ~5 { ~5 C3 M missingok
1 d. X4 b$ N) ~! b- M& b rotate 52
9 s9 S& g' ]. u [: m% y' U compress
( S. ^( O0 `% K, {1 d delaycompress - U) w$ \- k8 V+ R
notifempty
* @) j3 F! f8 u) O# n create 640 nginx adm - w% L! c. m6 u$ g& x- v a% R
sharedscripts 8 V& ~3 H( w3 Z; D" J
postrotate
* c0 `/ h# K3 h3 V% P, A [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
2 C5 Q) V( o9 E' ]: K6 X endscript ! n" N5 B w, M! V1 e! X
}
: f: `; k, H! Z) Z# bLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
" p$ }- R: e/ D( k1 H
/ `+ L) Y/ T- H3 N7 N
* F4 y9 g% i( n- E; A0 C蝵株牧:
& ^ K2 }- P" ]" Z b4 {0 rdaily:亥隞嗆憭拚脰皛曉
) q" I2 W% o. Ymissingok:憒曆圈log瑼獢,撠勗蕭仿
" Y' X7 q7 |& t% P6 h$ x, [( M" Zrotate:靽餈52甈⊥遝亥 % N1 T& d6 H H) p
compress:gzip憯蝮株脖誑敺亥 1 B: b' N7 E; {) A% G o0 C
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 2 e/ |2 h- U" Q
notifempty憒舐征隞嗥閰,銝頧
3 B* k" g# l1 I2 w/ l: V4 mcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 8 L" `7 u& L* @4 o8 O' W
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
7 B4 t) z+ N' r$ ppostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 % {5 T1 @1 V$ w) ?1 J a( f
9 N# r/ Z v; b3 ?, x8 p( d5 ilogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: 8 \; E' r/ }2 G7 `
/etc/cron.daily/logrotate+ @- ]- w) \2 F T) k4 E2 X
$ J: |$ }1 S+ U* P% D0 o閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
' J( F0 [3 Z+ O8 z7 i6 [sudo logrotate -vf /etc/logrotate.d/your-conf-file2 S# A1 q' s& J
' _! s: K E7 U4 W7 @( |: r
" k$ [/ V- l ]
4 E8 Z; A% Y; J+ H8 }- x; ]閮:5 g( H8 f: l2 x6 {9 ]
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
( C7 G2 g9 w1 V1 h$ W) t/ h @
% H7 J; B& P$ g6 |, |& y |
|