Thread: Deleting the pg logs older than 30 days or certain time
Hi All,
Can postgresql internal log rotation configuration mechanism delete the log files older than a specific period of time?
Is there a way to configure this as part of postgresql?
Regards,
Nikhil Ingale
Nikhil Ingale
Hi,
Le jeu. 29 juin 2023 à 09:13, Nikhil Ingale <niks.bgm@gmail.com> a écrit :
Hi All,Can postgresql internal log rotation configuration mechanism delete the log files older than a specific period of time?
No.
Is there a way to configure this as part of postgresql?
Nope, you'll have to configure logrotate.
--
Guillaume.
Guillaume Lelarge <guillaume@lelarge.info> writes: > Le jeu. 29 juin 2023 à 09:13, Nikhil Ingale <niks.bgm@gmail.com> a écrit : >> Can postgresql internal log rotation configuration mechanism delete the >> log files older than a specific period of time? > No. It will work if you choose a filename pattern such that old files are overwritten on some cycle. logrotate is a more flexible answer of course. regards, tom lane
example: log_filename = 'postgresql-%a.log'
Tom Lane wrote on 6/29/2023 7:22 AM:

Tom Lane wrote on 6/29/2023 7:22 AM:
Guillaume Lelarge <guillaume@lelarge.info> writes:Le jeu. 29 juin 2023 à 09:13, Nikhil Ingale <niks.bgm@gmail.com> a écrit :Can postgresql internal log rotation configuration mechanism delete the log files older than a specific period of time?No.It will work if you choose a filename pattern such that old files are overwritten on some cycle. logrotate is a more flexible answer of course. regards, tom lane
Regards,
Michael Vitale
703-600-9343

Attachment
I feel you have more control with a simple bash (or script of choice) one liner and cron. I don’t like automated deletes of anything unless I’m in control. $0.02
From: Nikhil Ingale <niks.bgm@gmail.com>
Sent: Thursday, June 29, 2023 12:12 AM
To: pgsql-admin@lists.postgresql.org
Subject: [EXTERNAL] Deleting the pg logs older than 30 days or certain time
Hi All,
Can postgresql internal log rotation configuration mechanism delete the log files older than a specific period of time?
Is there a way to configure this as part of postgresql?
Regards,
Nikhil Ingale