Re: rotatelog / logrotate with PostgreSQL

From: Yury Bokhoncovich <byg(at)center-f1(dot)ru>
To: Roland Roberts <roland(at)astrofoto(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: rotatelog / logrotate with PostgreSQL
Date: 2002-09-24 15:05:06
Message-ID: Pine.LNX.4.33.0209242156070.26040-100000@panda.center-f1.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

On 24 Sep 2002, Roland Roberts wrote:

> >>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
> Tom> "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com> writes:
> >> Can someone send an example of how they have the
> >> logrotate / rotatelog script working with PostgreSQL?
>
> Tom> Should work to just pipe the postmaster's stderr into it, eg
>
> Tom> postmaster ... 2>&1 | logrotate ... &
>
> Huh? logrotate moves a log file, it doesn't log anything.

Agreed.=)

>
> 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.

Try this:

./configure blah-blah-blah --enable-syslog
make&&make install and so on

then

postgresql.conf:
# requires ENABLE_SYSLOG
syslog = 2 # range 0-2
syslog_facility = 'LOCAL2'
syslog_ident = 'postgres'

logrotate.d/postgres:
/path/postgres.log
{
daily
compress
delaycompress
rotate 10
notifempty
create 640 root postgres
}

syslogd.conf:
local2.* /path/postgres.log

--
WBR, Yury Bokhoncovich, Senior System Administrator, NOC of F1 Group.
Phone: +7 (3832) 106228, ext.140, E-mail: byg(at)center-f1(dot)ru(dot)
Unix is like a wigwam -- no Gates, no Windows, and an Apache inside.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Berkus 2002-09-24 15:05:59 Re: [GENERAL] CURRENT_TIMESTAMP
Previous Message Bruno Wolff III 2002-09-24 15:04:38 Re: grant/revoke for alter/drop?