On Monday 21 December 2009 05:52:55 Dale wrote:
> Harry Putnam wrote:
> > Can anyone show me how to write a logrotate rule that will rotate on
> > either size or age?
> >
> > I use some very simple scripting for yrs but don't really see how to
> > rotate on more than one condition.
> >
> > I'd like to rotate a certain log weekly or over 7000k and keep no more
> > than 12 rotations for whatever reason.
> >
> > /var/log/debug.log {
> >    create 0600 reader wheel
> >     weekly || size=7000k
> >     rotate 12
> >     postrotate
> >       /etc/init.d/rsyslog reload > /dev/null 2>&1 || true
> >     endscript
> > }
> >
> > Is clearly NOT the right way to go.
> >
> > Any know how to do it?
> 
> man logrotate has a few examples that may help.  Here is one.
> 
>        "/var/log/httpd/access.log" /var/log/httpd/error.log {
>            rotate 5
>            mail w...@my.org
>            size 100k
>            sharedscripts
>            postrotate
>                /usr/bin/killall -HUP httpd
>            endscript
>        }
> 
> 
> I notice that the size part is on its own line which may be the issue.

That will rotate his log when it gets to 100k, and only when it gets to 100k.
The OP wants to rotate when either the log file is a certain size, or every 
week, whichever comes first.

Logrotate does not support that feature.

-- 
alan dot mckinnon at gmail dot com

Reply via email to