砍敺 IT_man 2016-11-3 21:24 蝺刻摩 . [( ^- ^2 M+ Z' E4 ?+ V, b0 v
) a `0 w6 [# Z4 L/ p: p1 g# d0 k+ Q( O
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.2 q' F/ W& A/ ^ @
曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
/ F, ]/ t3 t0 X* D Q# f潭臭敺亙酒erver銴鋆賡靘,摰.
) L# X# L4 v! u, d
, U7 j- S( \. X# I: `" Z. a: ]2 ^+ q
* e0 o0 V0 }+ M# g
隞乩隤芣亥蝞∠logrotate雿:
9 Q& ~$ w7 Y( M& m/ ^$ [- _/ |: m% }7 l7 ?# @4 Z
$ J3 [/ P2 S- H9 {* q, J8 A' t9 i摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
8 \. }: f' K) L7 F4 i/var/log/nginx/*.log { 7 e4 V" Z' O+ x
daily , d2 ~( Q' s' o; c' h/ W5 e3 p
missingok
+ s. K! S" p- O* y" r rotate 52 . g1 P& T4 F2 o" l; @$ p
compress
& h- _% _5 q9 z1 w6 ^2 a delaycompress % m" G1 E9 v6 f2 v7 K0 Y
notifempty
7 Y" Q3 D4 V+ \$ e% b create 640 nginx adm 9 F' b7 h+ B: M2 V; s B4 h
sharedscripts & Y% o: S' s* K# r H
postrotate ! P% D5 Y8 ~( X1 U. Y
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
% r, l# `) o, v; j+ l endscript
7 |; j$ V6 h2 W) K) H}
& X3 Q$ I' O/ z. e; mLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. ) p1 G( D- q! l( L) Z& @/ P: m1 Q7 m
: A) P7 T c9 x1 ~2 }
' A {" u! c( X2 y' a8 y蝵株牧:
& f4 S4 a$ z S8 ~daily:亥隞嗆憭拚脰皛曉 $ j$ N, E: h! h/ A; M/ Z
missingok:憒曆圈log瑼獢,撠勗蕭仿 $ Z: r+ W; W& a% A1 A5 g1 c
rotate:靽餈52甈⊥遝亥 # G K9 R" N( a. ]! m! x
compress:gzip憯蝮株脖誑敺亥 1 J3 T- X/ Q: o: X+ M9 m
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
( \0 s7 E7 T$ b' P* Znotifempty憒舐征隞嗥閰,銝頧 ) M1 s, k$ \$ Z2 S- a9 i+ F
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
7 P8 E4 }/ c h6 p, h7 i% B& T Osharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
2 z" d3 m) P% `# A5 W; Bpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 ( R. g$ v) Y1 X! H7 d$ W
( w' C: J& M& Q( v0 G2 s, d" glogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙:
6 n, u1 Z. d+ Y, W0 m/etc/cron.daily/logrotate# H1 J4 Z! D2 x9 o C
: ~$ q% w8 h# N- E+ w% V& D3 X* {4 y
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗1 ?) ?0 P8 ?' Q" z" }6 Z5 W
sudo logrotate -vf /etc/logrotate.d/your-conf-file
$ r( O9 _* H# i% ~- `3 N& s! b: l. J [% f2 T
4 w9 c, D. \5 [& g" P' }
6 |- a5 G* [0 v3 O9 {+ d, R閮:0 Y4 @% V% Q4 ]6 J3 V, e
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
j% Z& \+ i5 c- u( K: G7 o2 q& ?( ~# X1 a4 j4 ^/ H( V
|
|