砍敺 IT_man 2016-11-3 21:24 蝺刻摩 / g$ I! ]% {4 y6 I( `7 ~" B/ F5 W
' L8 C' T# l9 y+ {$ D7 jCentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
, \- B0 u' b$ N曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
?5 B0 a, G! R8 Y0 U: i' x潭臭敺亙酒erver銴鋆賡靘,摰.
9 a# N& e, ^% t$ k2 {/ e
2 U. z/ q% i5 C2 p! f) M: I n/ e# }; ~4 A/ }' c
, t; z+ h o& B2 y: u6 V# \/ ~隞乩隤芣亥蝞∠logrotate雿:
* A/ o; b7 c: l8 [9 d) o; r+ S7 n6 {" ]7 W1 ^$ R8 X# v
8 D. c( j" i5 f) I" ?0 h/ A摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx * G# G* t. O4 e# C- X3 u$ e# P
/var/log/nginx/*.log {
! k' ]1 t/ n6 X: ?: K daily + ]$ D2 k, u1 Z; [' W
missingok
- z, p& L* R0 q4 q) n rotate 52
/ f1 ]/ I- v5 K c/ e, A compress
' R! ]# T1 h- t7 s* |- p/ ? delaycompress " [7 I/ v3 ]. X, ]- g, _* X
notifempty ) a3 I3 D: q; s, Q
create 640 nginx adm
$ O0 ~; \$ {4 g+ B( u1 f) t sharedscripts
! f' H2 N: m3 m postrotate 2 O& V# M6 A% F0 Z. n* { t
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 3 j; F" D: c: I
endscript ( A- W: q& W, r
} ) [' a# Z) R/ B+ ~: \7 n
Linux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥. : J. v4 I5 b. A
$ I9 g; o; @6 c3 n4 c2 C @3 o. x& P4 w$ l1 p: z# K0 [
蝵株牧: ! E3 q+ a1 ], J* f
daily:亥隞嗆憭拚脰皛曉 ' N5 B4 H$ L U2 Q' N7 p
missingok:憒曆圈log瑼獢,撠勗蕭仿 ! w5 N! `* y& w3 `. y/ L
rotate:靽餈52甈⊥遝亥 % g" H X. k: q; ]& Z
compress:gzip憯蝮株脖誑敺亥 * z- g5 I! f1 D& s
delaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮
8 R, U0 R! B- J3 y3 n% Z7 E. Snotifempty憒舐征隞嗥閰,銝頧
: s. s+ G; e$ t9 x. F, E& e0 Hcreate mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞
$ o6 q) m2 v* a; v6 K8 jsharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞)
/ M$ z' r) z" x8 npostrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵
4 I0 k! J( Z) v0 w! b0 w
7 Y' H2 Z! g3 ~# \+ Slogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: / ?. }- ?+ r! w% N9 o
/etc/cron.daily/logrotate5 Z; W( g& V$ }- M& F7 E' H# q r
5 w8 b0 C, T( I& \7 ~# J
閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗
/ F5 g) m6 _! Z) g# p: o3 p+ M. Fsudo logrotate -vf /etc/logrotate.d/your-conf-file! \: Q7 l4 R% n5 I) C" m
/ R: y% f5 e3 W. Y/ K
L, ]: _+ ^ l+ u" e& ~! X" Y
; g5 _1 z( G. J, ?* Q" y, K4 }
閮:
g; Z9 W `; X$ ?: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
- u2 ?$ L% ~5 E7 S: F8 s* Q3 l$ e1 n8 S3 \
|
|