Re: Logrotate is a pain

From: Doug O'Leary (dkoleary_at_olearycomputers.com)
Date: 06/04/05


Date: Sat, 04 Jun 2005 11:40:01 -0700

On 2005-05-27, Fritz Bayer <fritz-bayer@web.de> wrote:
>
> Can you tell me where I can find a better replacement? The most
> important feature is that the program, which writes the logfiles does
> not have to be restarted or reload or anything else. That nobody has
> to touch it.

As mentioned, your best option would be to write a logrotate script
yourself. It's not difficult. The key aspect, that logrotate seems
to have missed is that if you rename an open log file, the processes
writing to it continues writing to it regardless of the name. The reason
is that the process is writing to an open inode; it really doesn't care
what the file's name is.

The proper way to do this is to copy the file to another location. Then,
when the copy is complete and the return code is checked, simply truncate
the log file.

For instance:

Date=$(date +"%y%m%d")
cp /var/log/httpd/access_log /var/log/httpd/access_log.${Date}
[[ $? -eq 0 ]] && > /var/log/httpd/access_log

That way the inode doesn't change and the process continues writing
to the original log file.

HTH

Doug

-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html


Relevant Pages

  • Re: Multi-Threading
    ... 100,000+ line log file and decided to use multi-threading as a solution to ... Multi-threading on the desktop is useful when you're executing long running ... getting the info is a problem or is writing it the database, ... Do Until intcount> intcount1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Set Trace to Ignore Errors in Trace.WriteLine?
    ... opened and locked - other processes should not be able to lock ... The problem appears to be something reading the log file not writing to it. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Hard Drive Space
    ... of the distribution, ... security problems it had over the life of the distribution. ... in the space, either the box is 0wn3d, or you have a process that is writing ... If you don't recall removing some log file manually, ...
    (linux.redhat)
  • Re: Logrotate is a pain
    ... >>important feature is that the program, which writes the logfiles does ... > to have missed is that if you rename an open log file, ... > writing to it continues writing to it regardless of the name. ... You can simply put a simple line in it to send SIGHUP to your daemon and the ...
    (comp.os.linux.misc)
  • Re: How to remove a single line from a flat file (Still very off-topic.)
    ... turn off syslog (so it's not writing to the file while you edit it), ... Editting includes rotating the log file, removing old entries, etc. ... part of the problem is the design of these files. ... more time/energy/money is spent on the admin juggling log files ...
    (comp.lang.tcl)