pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to maintain the csv log files in pg_log directory only for past 30 days
Date: Fri, 28 Sep 2018 08:31:46 -0500
Message-ID: <3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com> (raw)
In-Reply-To: <CAEHH7R4Sj+wr-imxcaSfMdr4eDJontxq68SxE8XC-dT9JABfWg@mail.gmail.com>
References: <CAEHH7R4Sj+wr-imxcaSfMdr4eDJontxq68SxE8XC-dT9JABfWg@mail.gmail.com>

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.

view thread (10+ messages)  latest in thread

Message-ID: <3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com>
Permalink:  ../3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com/
Also on:    postgresql.org/message-id/3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: How to maintain the csv log files in pg_log directory only for past 30 days
  In-Reply-To: <3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com>
  References: <CAEHH7R4Sj+wr-imxcaSfMdr4eDJontxq68SxE8XC-dT9JABfWg@mail.gmail.com> <3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox