Re: rotatelog / logrotate with PostgreSQL

Oliver Elphick <olly@lfix.co.uk>

From: Oliver Elphick <olly@lfix.co.uk>
To: Yury Bokhoncovich <byg@center-f1.ru>
Cc: Roland Roberts <roland@astrofoto.org>, pgsql-general@postgresql.org
Date: 2002-09-24T17:28:39Z
Lists: pgsql-general
On Tue, 2002-09-24 at 16:05, Yury Bokhoncovich wrote:
> > Does the postmaster close the log after writing?  logrotate can move
> 
> IIRC it closes file only on HUP or so, don't wanna to seek in sources.
> So if you don't use syslog, place killall -HUP `tail -n1 /pidpath/postmaster.pid`
> to postrotate clause and better use delaycompress if any.

> > the log and create a new (empty) one, but if the postmaster has the
> > log open, it will continue to write to the old one, defeating the
> > purpose of rotating the log.  Also, if logrotate is configured to
> > compress the log after rotating, an open connection will result in the
> > tail of the file being "corrupted" since uncompressed data will be
> > appended.

Use logrotate's copytruncate option to rotate an open file (when not
using syslog).  There is a small possibility of losing some log data in
between copying the log file and truncating it.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                            
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "And we know that all things work together for good to 
      them that love God, to them who are the called  
      according to his purpose."            
                                   Romans 8:28