Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D3C5863396F for ; Wed, 3 Feb 2010 17:39:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 87674-10 for ; Wed, 3 Feb 2010 21:38:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og116.obsmtp.com (exprod7og116.obsmtp.com [64.18.2.219]) by mail.postgresql.org (Postfix) with SMTP id 88C9F6324CC for ; Wed, 3 Feb 2010 17:38:56 -0400 (AST) Received: from source ([209.85.219.211]) by exprod7ob116.postini.com ([64.18.6.12]) with SMTP ID DSNKS2ns7hHwj3PWoIoBw5kX6L9qVFG/Kala@postini.com; Wed, 03 Feb 2010 13:38:56 PST Received: by mail-ew0-f211.google.com with SMTP id 3so1816819ewy.13 for ; Wed, 03 Feb 2010 13:38:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.89.213 with SMTP id c63mr75932wef.211.1265232829756; Wed, 03 Feb 2010 13:33:49 -0800 (PST) In-Reply-To: References: Date: Wed, 3 Feb 2010 16:33:49 -0500 Message-ID: Subject: Re: How to clear log files From: Scott Mead To: "Campbell, Lance" Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=0016e6d464cc603663047eb8f966 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201002/41 X-Sequence-Number: 33644 --0016e6d464cc603663047eb8f966 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Feb 3, 2010 at 4:12 PM, Campbell, Lance wrote: > PostgreSql:8.4.1 > > Is there a way for me to tell postgres to clear the log file. Example: I > have log files created with names corresponding to the days of the week. > This way they overwrite each other every week. When I deploy software > enhancements I would like to clear the log file for the day without having > to stop postgres. This way anything I see I know was after the deployment > of my enhancements. I tried to just delete the file with postgres running. > I found that it did not recreate the log file so I was forced to restart > postgres. > > > > Is there a command that might clear a log file or force it to rotate? > You should be able to set 'log_truncate_on_rotation=on' in postgresql.conf and then run: select pg_rotate_logfile(); That should rotate it, and if you have your log_filename setup with day of week only, it should truncate and restart in the same logfile. Haven't tested it, so I may be wrong, but it's worth a shot. --Scott --0016e6d464cc603663047eb8f966 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Feb 3, 2010 at 4:12 PM, Campbell, Lance = <lance@illinois.= edu> wrote:

PostgreSql:8.4.1

Is there a way for me to tell postgres to clear the = log file.=A0 Example:=A0 I have log files created with names corresponding to the days of the week.=A0 This way they overwrite each other every week.=A0 When I deploy software enhancements I would like to clear the log file for = the day without having to stop postgres.=A0 This way anything I see I know was after the deployment of my enhancements.=A0 I tried to just delete the file with postgres running.=A0 I found that it did not recreate the log file so = I was forced to restart postgres.

=A0

Is there a command that might clear a log file or fo= rce it to rotate?


You should be ab= le to set 'log_truncate_on_rotation=3Don' in postgresql.conf and th= en run:

select pg_rotate_logfile();

That should rotate it, and if you have your log_filename setup w= ith day of week only, it should truncate and restart in the same logfile. = =A0Haven't tested it, so I may be wrong, but it's worth a shot.

--Scott
--0016e6d464cc603663047eb8f966--