砍敺 IT_man 2016-11-3 21:24 蝺刻摩 , l4 R5 C. F! I; ?. j+ c( ?
9 z# v' J/ R U' D8 D* s! ~CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
; J( C7 K% d' |8 a( }) E曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
' O5 ?5 A7 t6 h }3 s8 M8 [2 q潭臭敺亙酒erver銴鋆賡靘,摰.3 ]! Y% }* S1 \7 X+ P6 u
: t9 O5 k; G2 X+ c0 Z
0 {$ w2 }5 I3 k2 n7 ~
6 z( V- i2 x3 y- H- x; o隞乩隤芣亥蝞∠logrotate雿:2 z0 C) ]1 q1 n1 v3 ^8 [6 ]
% L& \9 B: c3 F* A' P# [+ f" y
5 S B$ P9 S1 S- i2 {" b摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
8 ~' d! G; b8 @5 B! y+ A. ]) _/var/log/nginx/*.log {
- f6 R1 s* T0 n2 v) h( [ daily
! b1 a7 ^9 |0 M missingok
$ j% A0 S( s, w$ C- k5 c" h rotate 52 z; @, K+ P% K; m4 M* P6 z
compress
/ N, k: x; G" k delaycompress % f3 f" N4 u; X2 ]/ `. A; B
notifempty
: W6 f" b8 C) ~+ u! f+ V+ J- _+ w# Y create 640 nginx adm - j" B. i0 P# _7 m% \
sharedscripts 2 w0 }3 f1 E) _7 l3 m1 M+ P8 T
postrotate - E; |5 G' G' Z# m
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
4 y2 R: Y' P9 ?( v9 w* t3 w: b/ B endscript
6 w* v% a" S4 J3 h3 f}
" v" C: y" T4 E* M2 WLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. ! g. f# }! c' V L
0 N/ E( W x; l6 q# d; ^* T$ L& q, n5 o. E
蝵株牧:
4 b: [1 t) w9 Rdaily:亥隞嗆憭拚脰皛曉 ( G8 @, E, m! x/ x' |
missingok:憒曆圈log瑼獢,撠勗蕭仿 e# F! @+ X; W+ d3 y: H
rotate:靽餈52甈⊥遝亥 ( B! }( |7 j' O" f @# g
compress:gzip憯蝮株脖誑敺亥 3 n- E# T+ C8 R( y
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
/ R, w5 M6 |5 c6 x; o4 dnotifempty憒舐征隞嗥閰,銝頧
2 x8 I' z% q/ {1 d$ [' D& r+ Acreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 6 _3 T" o* t$ M1 h
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) 8 l* v/ m& x* R8 _* d. ^
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 $ F2 s0 U) v/ P- H" |
. k5 Y6 B1 ~5 z1 u/ k" K7 y3 A& d1 j
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: 2 a0 s: m3 O/ @& r. \$ r
/etc/cron.daily/logrotate
2 E3 V. R) a0 m5 f7 w$ @& v
, x9 w9 C9 ^6 l3 ?, u' e2 K閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
2 O; ?+ x. v( _& Tsudo logrotate -vf /etc/logrotate.d/your-conf-file4 f, h/ w5 y# W5 f2 i% w: c' H# G
8 j2 ^, `$ U# @+ ]0 [5 X( h& p# v9 s
# O$ ^4 ^/ }) o
. y" o) k% s# r7 p3 ^( w, {: s閮:
- i/ D1 l' |' L6 J: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
" j: y' ]; b! [( K" Q
' W3 `1 l' x2 ]0 N, @! j |
|