From: | Gabriel Guillem Barceló Soteras <gbarcelo(at)parlamentib(dot)es> |
---|---|
To: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Log file retention |
Date: | 2024-03-19 08:20:42 |
Message-ID: | DU0PR08MB7921BD36FAC04AA47FE72F3FA62C2@DU0PR08MB7921.eurprd08.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Date: Tuesday, 19 March 2024 at 09:16
To: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Log file retention
On Tue, Mar 19, 2024 at 4:04 AM Rajesh Kumar <rajeshkumar(dot)dba09(at)gmail(dot)com<mailto:rajeshkumar(dot)dba09(at)gmail(dot)com>> wrote:
Hi,
How to keep log files only for 7 days
logrotate? A bash script in a cron job?
I think it is the default behaviour on default install:
1. Edit the postgresql.conf File:
2. Locate the postgresql.conf file for your PostgreSQL installation.
3. Configure the Following Parameters:
* Set log_filename to server_log.%a. This will create one log file per day named server_log.Mon, server_log.Tue, etc.
* Enable log_truncate_on_rotation to automatically overwrite last week’s log with this week’s log.
* Set log_rotation_age to 1440 (minutes), which corresponds to 24 hours. This ensures that logs are rotated daily.
4. Example Configuration:
log_filename = 'server_log.%a'
log_truncate_on_rotation = on
log_rotation_age = 1440
Still keep an eye on log_rotation_size
After making these changes, restart your PostgreSQL server for the new settings to take effect.
From | Date | Subject | |
---|---|---|---|
Next Message | Rajesh Kumar | 2024-03-19 08:27:40 | Re: Log file retention |
Previous Message | Ron Johnson | 2024-03-19 08:15:54 | Re: Log file retention |