1 |
On Monday 21 December 2009 05:52:55 Dale wrote: |
2 |
> Harry Putnam wrote: |
3 |
> > Can anyone show me how to write a logrotate rule that will rotate on |
4 |
> > either size or age? |
5 |
> > |
6 |
> > I use some very simple scripting for yrs but don't really see how to |
7 |
> > rotate on more than one condition. |
8 |
> > |
9 |
> > I'd like to rotate a certain log weekly or over 7000k and keep no more |
10 |
> > than 12 rotations for whatever reason. |
11 |
> > |
12 |
> > /var/log/debug.log { |
13 |
> > create 0600 reader wheel |
14 |
> > weekly || size=7000k |
15 |
> > rotate 12 |
16 |
> > postrotate |
17 |
> > /etc/init.d/rsyslog reload > /dev/null 2>&1 || true |
18 |
> > endscript |
19 |
> > } |
20 |
> > |
21 |
> > Is clearly NOT the right way to go. |
22 |
> > |
23 |
> > Any know how to do it? |
24 |
> |
25 |
> man logrotate has a few examples that may help. Here is one. |
26 |
> |
27 |
> "/var/log/httpd/access.log" /var/log/httpd/error.log { |
28 |
> rotate 5 |
29 |
> mail www@××.org |
30 |
> size 100k |
31 |
> sharedscripts |
32 |
> postrotate |
33 |
> /usr/bin/killall -HUP httpd |
34 |
> endscript |
35 |
> } |
36 |
> |
37 |
> |
38 |
> I notice that the size part is on its own line which may be the issue. |
39 |
|
40 |
That will rotate his log when it gets to 100k, and only when it gets to 100k. |
41 |
The OP wants to rotate when either the log file is a certain size, or every |
42 |
week, whichever comes first. |
43 |
|
44 |
Logrotate does not support that feature. |
45 |
|
46 |
-- |
47 |
alan dot mckinnon at gmail dot com |