Re: Limiting the size of log files

From: Thom Brown <thom(at)linux(dot)com>
To: Amit Soni <get(dot)amitsoni(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Limiting the size of log files
Date: 2010-08-18 10:11:34
Message-ID: AANLkTimywpMNccKAYc9OAMaQYp8ftejOSZP22jsFaXek@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 18 August 2010 10:54, Amit Soni <get(dot)amitsoni(at)gmail(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Amit Soni 2010-08-18 10:34:14 Re: Limiting the size of log files
Previous Message Amit Soni 2010-08-18 09:54:29 Re: Limiting the size of log files