砍敺 IT_man 2016-11-3 21:24 蝺刻摩
# l5 I& _1 M: m" D, B% f: a" ~ S6 o7 t
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
) n+ S. W7 m" T4 z( g D3 v曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.7 l- b; W7 S V: q; @
潭臭敺亙酒erver銴鋆賡靘,摰.
- ]) C" ^* O( K+ _" A6 p; k7 m
: H0 w/ k) J# g) I- q
0 x; M# P( t& }: _+ v% C" `$ v
+ c0 Y+ x7 s7 ^, s! i2 Q% X* Z隞乩隤芣亥蝞∠logrotate雿:
1 ?% Z4 C) |1 s& @* J6 Z8 Y' c, U$ q" ^' M, k9 i" J% `1 w4 W- ?1 d/ E1 K
) \) U) K- L8 l6 }: ]/ y. L
摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
0 v5 R: w6 P! c9 a$ b/var/log/nginx/*.log {
' u- z2 | i4 g- d8 y7 n daily
: H) v. {) O8 B( q missingok
) m V3 j7 p% V" t' J U# a rotate 52 0 Q7 }, v; l% |. Z. h% j. s# T
compress + ~- J4 ~$ c" X4 O' F. x# i
delaycompress - K/ L% Q3 d5 e% M: { w
notifempty
1 Y; M' }0 L0 N% v create 640 nginx adm 2 {1 N5 Z0 H# S( V. H, E
sharedscripts 8 c2 M* t2 E Z8 Q
postrotate
! I" s3 A9 s8 {' t# R' H/ L1 z [ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
0 l! b S! H6 v" n endscript
: g% L" m; q& z' X6 @* @; `3 x7 @}
9 v7 s. _; l; T" \Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
" c/ L M2 ]! X9 ~* c
/ G& p9 F. t+ i+ C8 \
, `" m$ E3 d$ j+ w蝵株牧: 6 V5 e# |5 i* g" {1 x9 x/ @8 s
daily:亥隞嗆憭拚脰皛曉 ) ?! z/ T9 [$ I
missingok:憒曆圈log瑼獢,撠勗蕭仿
& @) P9 k: C7 H2 v. @& rrotate:靽餈52甈⊥遝亥
6 [4 n. I; M6 F' \& icompress:gzip憯蝮株脖誑敺亥 ' J' ~5 t" b. S' J4 W( I' d; F3 \
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
0 ^8 d+ a3 v G1 d7 a# ^notifempty憒舐征隞嗥閰,銝頧 2 W4 `0 f, p: k. {& @: X6 i
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
( R2 b' [1 _: w, jsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
% p1 a1 J; H' C2 T4 B8 ]5 K; r# Tpostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
7 C6 ^- I* P0 o/ E" j% {5 a2 Q" X4 c8 J# N0 w
logrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: ) S; u6 w0 j! B( b X' w/ |
/etc/cron.daily/logrotate/ i r+ N4 \$ Z8 _% \! a) r0 C
- V* G! S# p ^: c
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗) H; D8 l: m" x3 @0 k
sudo logrotate -vf /etc/logrotate.d/your-conf-file! M- Y2 a! S" e( e+ d- A4 H. ]! S6 w
, @" w( q5 q. G8 M) G! o" L0 A
) `& | j+ U Z- u& }8 w
5 r8 b8 }+ r; Z. y2 o0 B+ g! e閮:2 d& s2 W, W. n( K' `
: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html; X) W1 ^! Q% U- ^& ?! n0 y/ x$ L
9 p, W7 ~/ x7 `' }( i
|
|