1 |
Harry Putnam wrote: |
2 |
> Can anyone show me how to write a logrotate rule that will rotate on |
3 |
> either size or age? |
4 |
> |
5 |
> I use some very simple scripting for yrs but don't really see how to |
6 |
> rotate on more than one condition. |
7 |
> |
8 |
> I'd like to rotate a certain log weekly or over 7000k and keep no more |
9 |
> than 12 rotations for whatever reason. |
10 |
> |
11 |
> /var/log/debug.log { |
12 |
> create 0600 reader wheel |
13 |
> weekly || size=7000k |
14 |
> rotate 12 |
15 |
> postrotate |
16 |
> /etc/init.d/rsyslog reload > /dev/null 2>&1 || true |
17 |
> endscript |
18 |
> } |
19 |
> |
20 |
> Is clearly NOT the right way to go. |
21 |
> |
22 |
> Any know how to do it? |
23 |
> |
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 |
Dale |
41 |
|
42 |
:-) :-) |