砍敺 IT_man 2016-11-3 21:24 蝺刻摩
0 e' b. v, e* y# p& m# D' z4 u( J) B3 B& j
CentOS銝nginxlog瑼曉/var/log/nginx,雿亦餅鋡怨芸脖蒂憯蝮.
h7 f7 {' j0 u0 Q4 Z+ t- z$ }. J曆google潛曉靘蝻箏鈭/etc/logrotate.d/nginx瑼,抒摰鋆nginx閰脫芸Y甇斗,箔銝芸Y,航賣臬鋆箔撌桅.
9 m e1 o3 A3 H' {4 R2 P潭臭敺亙酒erver銴鋆賡靘,摰.
& F& T3 [- b7 B9 Z6 p) |
2 \. T; f* v3 y" ^1 G
4 q" Q; M- y& k0 o9 u, r2 D0 y
5 v# Z# [4 E' A9 n隞乩隤芣亥蝞∠logrotate雿:& t' f( X4 E! K6 d# `( X* R6 n7 V
7 P. L; H0 R N, b; B( i2 U
0 L; ?8 E, M+ X$ y3 [& G0 N4 [摸ginx典鋆乩銝logrotate隞餃: /etc/logrotate.d/nginx
$ n! ]$ P& c5 Q/ v. m$ [- {/ t/var/log/nginx/*.log { 7 G. Y- a6 F3 I3 S2 {$ x& ^5 Y
daily
" J: a9 [' j3 z; b3 ~ missingok & h, F% O1 h, l& t. H I. j
rotate 52
- x$ \3 H- L- ?; k' H compress 1 Z3 h# _3 S: d
delaycompress
' d. L4 G5 I l. H# M9 f notifempty
) _& E- j7 r# Z/ m% M& s+ h create 640 nginx adm
0 F! {, u) @3 Y& m0 j: m( m+ u sharedscripts ( `9 i' m! }: ^. T* t
postrotate 3 y) S5 I* A; {8 J4 R# A! }
[ -f /var/run /nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
) ^2 |# r' g& T' a endscript
- u" N, L' y' i. M% Z, T}
, Q: ?1 F' F- P* ZLinux亥蝞∠logrotate摰霈閰脫隞,寞閮剔蔭亥憭批憭拇詨芷/甇豢亥,撱箇唳亥.
8 k. L6 ^0 r" L6 ?9 l4 C" P/ p
5 ~4 r4 R; I9 ]! f) i
0 Z7 T" | _& [8 Z a蝵株牧: 9 B1 U: O7 K! {9 g% Q' N
daily:亥隞嗆憭拚脰皛曉
) D' R, C! a, K: umissingok:憒曆圈log瑼獢,撠勗蕭仿 + P# [1 x* ^7 T* U6 f' U
rotate:靽餈52甈⊥遝亥 ; e+ v7 c! U( x% O
compress:gzip憯蝮株脖誑敺亥
% @- e7 r5 x( x4 adelaycompress:compress銝韏瑚蝙冽,頧脩亥隞嗅唬銝甈∟脫憯蝮 9 C" Y- r+ o% ]0 C
notifempty憒舐征隞嗥閰,銝頧 ~ n) q i+ _* q3 s0 x
create mode owner group:頧脫隞,雿輻冽摰隞嗆芋撘撱箇啁亥隞 ( p/ g) }$ e( M9 [# h1 t8 A
sharedscripts:銵postrotate單(閰脰單砌函箄nginx啁亥隞) : z5 t8 i* Z* |
postrotate/endscript:刻脖誑敺閬瑁賭誘臭誑曉仿餈啣鋆,拙萄敹桃冽銵 ( g% ^/ [( ]4 e* x/ [0 U6 \
1 i+ `# s1 H. f- B% N! I& ], rlogrotate閮剛◤亙軏ron/etc/cron.daily銝凋箸乩遙瑁,蝵桀蝢拙: : P \) y. B" q$ I% b, L
/etc/cron.daily/logrotate
* b# O8 L1 n/ h
$ m7 k/ x5 @- J3 u7 m) A閬皜祈岫撖怠末閮剖瑼臭誑其誑銝賭誘嚗) B, s+ s- S# n4 C8 [9 ^8 D0 F
sudo logrotate -vf /etc/logrotate.d/your-conf-file' F3 ]& x, \ u9 e/ ]( |! H4 @
2 Z7 c+ V- o/ a9 V+ D( e4 h
+ X/ N9 W: b# K6 Z8 A$ I, j* @0 `5 h- e4 C0 U+ u" k3 j. h4 k. D
閮:
' ^, X9 S7 i& h" J9 l- [: https://blog.toright.com/posts/4 ... AD%B8%E6%AA%94.html
/ c N% W" I1 @5 ]/ |3 i$ Q
% C: G) ~6 G, f; k c |
|