Re: How to maintain the csv log files in pg_log directory only forpast 30 days - Mailing list pgsql-general

From Ron
Subject Re: How to maintain the csv log files in pg_log directory only forpast 30 days
Date
Msg-id 3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com
Whole thread Raw
In response to How to maintain the csv log files in pg_log directory only for past30 days  (Raghavendra Rao J S V <raghavendrajsv@gmail.com>)
List pgsql-general
On 09/28/2018 12:03 AM, Raghavendra Rao J S V wrote:

Hi All,

Log file will be generated in csv format at pg_log directory in our PostgreSQL. Every day we are getting one log file. We would like to maintain only max 30 days. Which setting need to modify by us in “postgresql.conf” in order to recycle the log files after 30 days.

Does it have to be in postgresql.conf?  A cron job which runs a few minutes after midnight works just fine.

Compresses yesterday's log file and deletes files older than 30 days:
#!/bin/bash
DIR=/var/lib/pgsql/data/pg_log
cd $DIR
PREVDT=$(date -d "-1 day" +"%F")
bzip2 -9 postgresql-${PREVDT}.log
OLDFILES=$(find $DIR/postgresql-*log* -mtime +30)
rm -v $OLDFILES



--
Angular momentum makes the world go 'round.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Why my query not using index to sort?
Next
From: Tom Lane
Date:
Subject: Re: Why my query not using index to sort?