On Oct 07, 2003 Paul Martin wrote:
> On Tue, Oct 07, 2003 at 01:29:15PM +0200, Anders Henke wrote:
> > Package: logrotate
> > Version: 3.5.9-8
> > Severity: wishlist
> >
> > For archiving older logfiles it's often a good idea to move them
> > to a larger disk array, freeing up /var/log from non-current logfiles.
> >
> > However, logrotate requires to have its old logfiles on the same disk
> > device, so this idea doesn't work. Obvious (and bad) workaround: mount
> > the large disk array to /var/log :-)
>
> The reason logrotate has this requirement is that it uses rename (2) to
> do the rotation. Why does it do this? The logfile can still be open by
> the logging program (which is why there's the delaycompress option).

It is not true in point of fact.

When one use in configuration file 'copytruncate' option logrotate use
'static int copyTruncate' function
with following algorithm:

1 read from original file descriptor 'fdcurr'
2 write to target file descriptor 'fdsave'
3 truncate original file with 'ftruncate(fdcurr, 0)' syscall

Therefore, I think it is a bug in logrotate when it read its configuration
(config.c):

it has:
    if (sb.st_dev != sb2.st_dev) {

it should be:
     if (sb.st_dev != sb2.st_dev && !(newlog->flags &
LOG_FLAG_COPYTRUNCATE)) {

I supply a little patch for this bug.

Thank you,

Sergey Kryaczevskih

Attachment: olddir-214549.patch
Description: Binary data

Reply via email to