Re: Limiting the size of log files - Mailing list pgsql-novice

From Thom Brown
Subject Re: Limiting the size of log files
Date
Msg-id AANLkTimywpMNccKAYc9OAMaQYp8ftejOSZP22jsFaXek@mail.gmail.com
Whole thread Raw
In response to Re: Limiting the size of log files  (Amit Soni <get.amitsoni@gmail.com>)
Responses Re: Limiting the size of log files  (Amit Soni <get.amitsoni@gmail.com>)
List pgsql-novice
On 18 August 2010 10:54, Amit Soni <get.amitsoni@gmail.com> wrote:
> I tried this and the limit on the log file size works.
> The reason I didn't tried this before is that, I would probably have GB's of
> logs and the space consumed on the disk would be same in this case also with
> only difference in the number of file. Do we have some kind of pattern that
> would repeat itself so that we can have let's say only five log files which
> rotate themselves.
>

Yes, you can set "log_truncate_on_rotation" to "on" and adjust the
filename pattern.  However, I'd recommend not using size-based
rotation, but rather time-based.

So change:

log_filename to "postgresql-%H"
log_rotation_age to 60
log_rotation_size to 0

The log files will start being rotated after 24 hours as it will start
overwriting previous hours.

However, I'm not entirely sure how PostgreSQL decides to rotate "after
60 minutes".  If you start PostgreSQL at, say, 12:44, it would create:

postgresql-12.sql

At 13:44 I guess it would say "I need to rotate", so creates:

postgresql-13,.sql

So postgresql-12.sql contains log entries from 12:44 to 13:43.  If
this is the case, just bear it in mind and don't assume something like
"postgresql-15.sql" contains log entries from 15:00:00 to 15:59:59.

--
Thom Brown
Registered Linux user: #516935

pgsql-novice by date:

Previous
From: Amit Soni
Date:
Subject: Re: Limiting the size of log files
Next
From: Amit Soni
Date:
Subject: Re: Limiting the size of log files