Re: How to maintain the csv log files in pg_log directory only forpast 30 days

Поиск
Список
Период
Сортировка
От Ron
Тема Re: How to maintain the csv log files in pg_log directory only forpast 30 days
Дата
Msg-id 3b246f3b-221e-8988-e9d5-91848a5ffcb3@gmail.com
обсуждение исходный текст
Ответ на How to maintain the csv log files in pg_log directory only for past30 days  (Raghavendra Rao J S V <raghavendrajsv@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Why my query not using index to sort?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why my query not using index to sort?