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.

Reply via email to