Re: Logrotate is a pain
From: Jean-David Beyer (jdbeyer_at_exit109.com)
Date: 06/04/05
- Next message: Peter T. Breuer: "Re: Logrotate is a pain"
- Previous message: Kevin Nathan: "Re: icewm window decorations"
- In reply to: Doug O'Leary: "Re: Logrotate is a pain"
- Next in thread: Peter T. Breuer: "Re: Logrotate is a pain"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 04 Jun 2005 15:48:33 -0400
Doug O'Leary wrote:
> 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.
>
Why make your life so difficult? Use logrotate as it is meant to be used.
You can simply put a simple line in it to send SIGHUP to your daemon and the
daemon, if properly written, will close its logfile and re-open it. Here is
the entry for the syslog daemon and some of its friends:
[/etc/logrotate.d]$ cat syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler
/var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null
|| true
endscript
}
-- .~. Jean-David Beyer Registered Linux User 85642. /V\ PGP-Key: 9A2FC99A Registered Machine 241939. /( )\ Shrewsbury, New Jersey http://counter.li.org ^^-^^ 15:40:00 up 6 days, 22:15, 5 users, load average: 5.45, 5.12, 4.60
- Next message: Peter T. Breuer: "Re: Logrotate is a pain"
- Previous message: Kevin Nathan: "Re: icewm window decorations"
- In reply to: Doug O'Leary: "Re: Logrotate is a pain"
- Next in thread: Peter T. Breuer: "Re: Logrotate is a pain"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|