[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is it possible to do this using logrotate?



I am executing logrotate manually, using same user id as the process
which is appending to the log file in question.

I looked more closely at what is happening and actually the log file
IS being truncated by logrotate, however as soon as the logging process
writes to the log file again it is restored to it's original size and
grows from there again.  The original content of the file is sometimes
garbled however, up to the point where it was truncated, which I hadn't
noticed originally.

I was skeptical when I read the original docs on logrotate's copytruncate
option, because I had never been able to have 2 unix processes write 
concurrently to the same block file descriptor in any sensible way before.  
I thought perhaps logrotate had discovered some magical way to do this but 
it appears not.

If this is the case then I don't see any purpose for the copytruncate
option here at all actually.  

Thanks,
Steve

On 10 Aug 2001, Michael Heldebrant wrote:

> Does the logrotate process you run have enough permissions to write to
> the file it's trying to truncate?  It seems to have enough permissions
> to copy it, but not to write it.  Check to see if you as a user can
> write to the file since my logrotate command has no suid bit set.
> 
> --mike
> 
> On 10 Aug 2001 15:46:34 -0400, Steve McWilliams wrote:
> > 
> > 
> > >Steve McWilliams <stevemc@Radix.Net> writes:
> > >
> > >> I wonder if anyone has experience with the logrotate utility and can
> > >> answer a question about it for me.  After reading the man page discussion
> > >> about a copytruncate option, it sounded like it was somehow possible
> > >> to copy off a log file and truncate it to length 0, and allow the
> > >> logging process to continue unaffected.
> > >> 
> > >> After trying this however the behavior I'm seeing is that the log is
> > >> copied off, and the logging process is able to continue writing to
> > >> the same file descriptor, but the log is not correctly truncated.
> > >
> > >How is it failing exactly?
> > 
> > If I have the following logrotate config file for instance:
> > 
> > /tmp/foo.log {
> >     rotate 5
> >     size=1k
> >     copytruncate
> > }
> > 
> > I have a process which is appending to this file frequently.  When
> > the log file has exceeded 1k I manually invoke logrotate.  It copies
> > /tmp/foo.log to /tmp/foo.log.1 as expected, however the size and 
> > contents of the original /tmp/foo are unaffected.  The /tmp/foo file
> > continues to grow in size and is never truncated.  What I expected to 
> > see according to the documentation was /tmp/foo reset to 0 size and 
> > grow from there.
> > 
> > >> I realize this isn't strictly speaking a debian question, so I apologize
> > >> in advance if this isn't the correct forum for this question.
> > >
> > >Anyway, debian-mentor is for packaging-related questions, so it would
> > >be more appropriate to debian-user. So please heed the reply-to.
> > >
> > >-- 
> > >Robbe
> > 
> > I see.  I just tried subscribing to this list but got a bounce for some
> > reason.  I'll try to post questions like this there in future though.
> > 
> > Thanks,
> > Steve
> > 
> > 
> > 
> > -- 
> > To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> > with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> > 
> > 
> 
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 



Reply to: