pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to clear log files
4+ messages / 4 participants
[nested] [flat]

* How to clear log files
@ 2010-02-03 21:12 Campbell, Lance <lance@illinois.edu>
  2010-02-03 21:33 ` Re: How to clear log files Scott Mead <scott.lists@enterprisedb.com>
  2010-02-03 21:36 ` Re: How to clear log files Plugge, Joe R. <JRPlugge@west.com>
  2010-02-04 00:46 ` Re: How to clear log files Gabriel Parrondo <gabriel.parrondo@ultragestion.com.ar>
  0 siblings, 3 replies; 4+ messages in thread

From: Campbell, Lance @ 2010-02-03 21:12 UTC (permalink / raw)
  To: pgsql-admin

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?

 

Thanks,

 

Lance Campbell

Software Architect/DBA/Project Manager

Web Services at Public Affairs

217-333-0382

 

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to clear log files
  2010-02-03 21:12 How to clear log files Campbell, Lance <lance@illinois.edu>
@ 2010-02-03 21:33 ` Scott Mead <scott.lists@enterprisedb.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Scott Mead @ 2010-02-03 21:33 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; +Cc: pgsql-admin

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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to clear log files
  2010-02-03 21:12 How to clear log files Campbell, Lance <lance@illinois.edu>
@ 2010-02-03 21:36 ` Plugge, Joe R. <JRPlugge@west.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Plugge, Joe R. @ 2010-02-03 21:36 UTC (permalink / raw)
  To: Campbell, Lance <lance@illinois.edu>; pgsql-admin

What platform?  If in Unix/Linux, just:

 cat /dev/null > postgres_logfile

or                   > postgres_logfile

Most running programs don't like it when you delete a file with an open file handle but you it doesn't mind if you clear it on the fly.  Not sure how to do this in a Windows environment.

From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Campbell, Lance
Sent: Wednesday, February 03, 2010 3:13 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] How to clear log files

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?

Thanks,

Lance Campbell
Software Architect/DBA/Project Manager
Web Services at Public Affairs
217-333-0382

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to clear log files
  2010-02-03 21:12 How to clear log files Campbell, Lance <lance@illinois.edu>
@ 2010-02-04 00:46 ` Gabriel Parrondo <gabriel.parrondo@ultragestion.com.ar>
  2 siblings, 0 replies; 4+ messages in thread

From: Gabriel Parrondo @ 2010-02-04 00:46 UTC (permalink / raw)
  To: pgsql-admin

El mié, 03-02-2010 a las 15:12 -0600, Campbell, Lance escribió:
> 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.
> 
Actually, when you delete an opened file it isn't really deleted.
Whatever program opened it can still read/write to it using the file
descriptor.

> Is there a command that might clear a log file or force it to rotate?
Truncating it like this should work:
echo > /path/to/logfile

There's probably a better way though.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2010-02-04 00:46 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-02-03 21:12 How to clear log files Campbell, Lance <lance@illinois.edu>
2010-02-03 21:33 ` Scott Mead <scott.lists@enterprisedb.com>
2010-02-03 21:36 ` Plugge, Joe R. <JRPlugge@west.com>
2010-02-04 00:46 ` Gabriel Parrondo <gabriel.parrondo@ultragestion.com.ar>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox