Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5ss5-0006I8-Ne for pgsql-general@arkaria.postgresql.org; Fri, 28 Sep 2018 13:31:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5ss4-0002SF-0B for pgsql-general@arkaria.postgresql.org; Fri, 28 Sep 2018 13:31:52 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5ss3-0002S7-IH for pgsql-general@lists.postgresql.org; Fri, 28 Sep 2018 13:31:51 +0000 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g5ss0-0006xe-Qn for pgsql-general@lists.postgresql.org; Fri, 28 Sep 2018 13:31:50 +0000 Received: by mail-ot1-x343.google.com with SMTP id q4-v6so5987356otf.13 for ; Fri, 28 Sep 2018 06:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=xfMC+HzduKTxgdzJ5iA+5+CMBMoT8ZjA5xM3hdiRGFw=; b=QVwGVDeAukRNQYfe+8NXoc0G4jwhzIQPtasUkIoKNFa/hjtIPHlbA8UxjsL4qoyJ2O hrcA5FTkLX/Sjq2agMJRsHtNVImT8A6iwBmAu0l2fIPSfNpzhXUqddWHaDmb4TKnqhQh FRFPtjraZXsV4RIhFnbCuDx11itE+N2iuPPn7HtjPs1u9VRv8CbbKS8GdN0K3U3MFVuY lQyPBUK76zgzEmzXmiBTe4rUZaN3lo8BsiJtaeOOg2OWh10NC9r6xsIu4NjG0AQssalb 5bdotvSSBC2RjXWo/xRYPrD9k/seLu/KYj8SL9Gl/i9COcfj/YhM82SSNMoSBC3B3Ihy hFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=xfMC+HzduKTxgdzJ5iA+5+CMBMoT8ZjA5xM3hdiRGFw=; b=syhhFjFXCFNlrOU/rBXBiKbwOUckn2+Sw8zUbVEcggZZ2GgnNoxESi+1t7VBuaYWhA 4MWQgisr3uYkEH3FsgF8rASjlrfrAhgAoDaKRDo9r6zrzAZIrLl72rLcaurXL4z9T7SQ lwFyzumP2qXv+UBkSrHw30NDDbYXaaRkM8nyHedoDFTXfeNqaNk5Fk2usTHcJ0OMW7fs QuFDTIsHZhz2TsiR5Chtm2hawYGsRkrbTRkWtFMRkhzlF9SesWMKDOQsUonOsF9WgCUj CKBMYhlDJ4AHwh2aKyS2TKlx4pKKDr0yormWCNMQAKvMLLPlCdO4UFT+VrdKD41AJ6kK oIyA== X-Gm-Message-State: ABuFfogAhLDM9dOMsGrnWv5T1K9ZgRsawMwoebMbGp3Fo9LAyoW3sqQr 21ARWu5jvMEa6CVLg8jFa+nX5vI2 X-Google-Smtp-Source: ACcGV600Xm5OnxwcC39FlzHkSIXKunubp5ENrnQ8aRJDU6bV8blCU5t70eMl+bUwUzqOhZFGhzDxMw== X-Received: by 2002:a9d:4a91:: with SMTP id i17-v6mr3930974otf.364.1538141507586; Fri, 28 Sep 2018 06:31:47 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id w191-v6sm1877161oif.52.2018.09.28.06.31.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 06:31:46 -0700 (PDT) Subject: Re: How to maintain the csv log files in pg_log directory only for past 30 days To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: <3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com> Date: Fri, 28 Sep 2018 08:31:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------7EB538CAD162FC8F30BEAB8C" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7EB538CAD162FC8F30BEAB8C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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. --------------7EB538CAD162FC8F30BEAB8C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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.
--------------7EB538CAD162FC8F30BEAB8C--