Re: Logrotate is a pain
From: Doug O'Leary (dkoleary_at_olearycomputers.com)
Date: 06/04/05
- Next message: Kevin Nathan: "Re: icewm window decorations"
- Previous message: Tony Lawrence: "Re: If my httpd.conf is damaged"
- Next in thread: Jean-David Beyer: "Re: Logrotate is a pain"
- Reply: Jean-David Beyer: "Re: Logrotate is a pain"
- Reply: Peter T. Breuer: "Re: Logrotate is a pain"
- Reply: Unruh: "Re: Logrotate is a pain"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Kevin Nathan: "Re: icewm window decorations"
- Previous message: Tony Lawrence: "Re: If my httpd.conf is damaged"
- Next in thread: Jean-David Beyer: "Re: Logrotate is a pain"
- Reply: Jean-David Beyer: "Re: Logrotate is a pain"
- Reply: Peter T. Breuer: "Re: Logrotate is a pain"
- Reply: Unruh: "Re: Logrotate is a pain"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|