pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to maintain the csv log files in pg_log directory only for past 30 days
10+ messages / 6 participants
[nested] [flat]
* How to maintain the csv log files in pg_log directory only for past 30 days
@ 2018-09-28 05:03 Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-28 13:28 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Francisco Olarte <folarte@peoplecall.com>
2018-09-28 13:31 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Ron <ronljohnsonjr@gmail.com>
0 siblings, 3 replies; 10+ messages in thread
From: Raghavendra Rao J S V @ 2018-09-28 05:03 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
--
Regards,
Raghavendra Rao J S V
Mobile- 8861161425
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-09-28 05:25 ` Michael Paquier <michael@paquier.xyz>
2018-09-28 06:13 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 13:19 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
2 siblings, 2 replies; 10+ messages in thread
From: Michael Paquier @ 2018-09-28 05:25 UTC (permalink / raw)
To: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On Fri, Sep 28, 2018 at 10:33:30AM +0530, Raghavendra Rao J S V wrote:
> 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.
If you use for example log_filename = 'postgresql-%d.log', then the
server uses one new file every day. This truncates the contents from
the last month automatically.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
@ 2018-09-28 06:13 ` Raghavendra Rao J S V <raghavendrajsv@gmail.com>
1 sibling, 0 replies; 10+ messages in thread
From: Raghavendra Rao J S V @ 2018-09-28 06:13 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org
Thanks for the prompt response.
On Fri 28 Sep, 2018, 10:55 AM Michael Paquier, <michael@paquier.xyz> wrote:
> On Fri, Sep 28, 2018 at 10:33:30AM +0530, Raghavendra Rao J S V wrote:
> > 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.
>
> If you use for example log_filename = 'postgresql-%d.log', then the
> server uses one new file every day. This truncates the contents from
> the last month automatically.
> --
> Michael
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
@ 2018-09-28 13:19 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-28 22:54 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 10+ messages in thread
From: Adrian Klaver @ 2018-09-28 13:19 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; Raghavendra Rao J S V <raghavendrajsv@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On 9/27/18 10:25 PM, Michael Paquier wrote:
> On Fri, Sep 28, 2018 at 10:33:30AM +0530, Raghavendra Rao J S V wrote:
>> 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.
>
> If you use for example log_filename = 'postgresql-%d.log', then the
> server uses one new file every day. This truncates the contents from
> the last month automatically.
If log_truncate_on_rotation = 'on', correct?
> --
> Michael
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-28 13:19 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-09-28 22:54 ` Michael Paquier <michael@paquier.xyz>
2018-09-29 02:05 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Michael Paquier @ 2018-09-28 22:54 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; pgsql-general@lists.postgresql.org
On Fri, Sep 28, 2018 at 06:19:16AM -0700, Adrian Klaver wrote:
> If log_truncate_on_rotation = 'on', correct?
Yup, thanks for precising.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-28 13:19 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-28 22:54 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
@ 2018-09-29 02:05 ` Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-29 14:12 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 10+ messages in thread
From: Raghavendra Rao J S V @ 2018-09-29 02:05 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
Hi All,
Hope you all are recommending below settings to maintain only max 30 days
logs in *pg_log* directory. Please correct me if I am wrong.
log_filename = 'postgresql-%d.log'
log_truncate_on_rotation = 'on',
Regards,
Raghavendra Rao
On Sat, 29 Sep 2018 at 04:24, Michael Paquier <michael@paquier.xyz> wrote:
> On Fri, Sep 28, 2018 at 06:19:16AM -0700, Adrian Klaver wrote:
> > If log_truncate_on_rotation = 'on', correct?
>
> Yup, thanks for precising.
> --
> Michael
>
--
Regards,
Raghavendra Rao J S V
Mobile- 8861161425
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-28 13:19 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-28 22:54 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-29 02:05 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-09-29 14:12 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-30 09:50 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 1 reply; 10+ messages in thread
From: Adrian Klaver @ 2018-09-29 14:12 UTC (permalink / raw)
To: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org
On 9/28/18 7:05 PM, Raghavendra Rao J S V wrote:
> Hi All,
>
> Hope you all are recommending below settings to maintain only max 30
> days logs in *pg_log* directory. Please correct me if I am wrong.
Well it would actually be 31 days as:
http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
%d
Replaced by the day of the month as a decimal number [01,31]. [
tm_mday]
Not sure if that matters or not.
>
> log_filename = 'postgresql-%d.log'
> log_truncate_on_rotation = 'on',
>
> Regards,
> Raghavendra Rao
>
> On Sat, 29 Sep 2018 at 04:24, Michael Paquier <michael@paquier.xyz
> <mailto:michael@paquier.xyz>> wrote:
>
> On Fri, Sep 28, 2018 at 06:19:16AM -0700, Adrian Klaver wrote:
> > If log_truncate_on_rotation = 'on', correct?
>
> Yup, thanks for precising.
> --
> Michael
>
>
>
> --
> Regards,
> Raghavendra Rao J S V
> Mobile- 8861161425
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-28 13:19 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-28 22:54 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Michael Paquier <michael@paquier.xyz>
2018-09-29 02:05 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-29 14:12 ` Re: How to maintain the csv log files in pg_log directory only for past 30 days Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-09-30 09:50 ` Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 0 replies; 10+ messages in thread
From: Peter J. Holzer @ 2018-09-30 09:50 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2018-09-29 07:12:32 -0700, Adrian Klaver wrote:
> On 9/28/18 7:05 PM, Raghavendra Rao J S V wrote:
> > Hope you all are recommending below settings to maintain only max 30
> > days logs in *pg_log* directory. Please correct me if I am wrong.
>
> Well it would actually be 31 days as:
>
> http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
>
> %d
> Replaced by the day of the month as a decimal number [01,31]. [ tm_mday]
Additionally, the log file for the 31st of a month is usually only
overwritten after 61 days.
> Not sure if that matters or not.
It may or may not. Personally I prefer to use find -mtime (or logrotate,
or cleandir, or keepfree, ...) to avoid the irregularities of the
Gregorian calendar.
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-09-28 13:28 ` Francisco Olarte <folarte@peoplecall.com>
2 siblings, 0 replies; 10+ messages in thread
From: Francisco Olarte @ 2018-09-28 13:28 UTC (permalink / raw)
To: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Fri, Sep 28, 2018 at 7:03 AM, Raghavendra Rao J S V
<raghavendrajsv@gmail.com> wrote:
> 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.
I have similar problems in a lot of things and normally use "find
<directory> -name <whatever> -mtime +<age> -delete" in the daemons
cron ( gnu find, on linux, I assume other os have a similar command ).
For postgres-only solutions you've been given some advice previously,
and like those I only know ways to do it daily/weekly/monthly/yearly.
Francisco Olarte.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: How to maintain the csv log files in pg_log directory only for past 30 days
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-09-28 13:31 ` Ron <ronljohnsonjr@gmail.com>
2 siblings, 0 replies; 10+ messages in thread
From: Ron @ 2018-09-28 13:31 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2018-09-30 09:50 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-28 05:03 How to maintain the csv log files in pg_log directory only for past 30 days Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 05:25 ` Michael Paquier <michael@paquier.xyz>
2018-09-28 06:13 ` Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-28 13:19 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-28 22:54 ` Michael Paquier <michael@paquier.xyz>
2018-09-29 02:05 ` Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-09-29 14:12 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-09-30 09:50 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2018-09-28 13:28 ` Francisco Olarte <folarte@peoplecall.com>
2018-09-28 13:31 ` Ron <ronljohnsonjr@gmail.com>
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