Postgresql – Rotate Postgres log at 5GB

postgresqlpostgresql-9.1

How to make postgres 9.1 log to have maximum size 5GB and to be circle when comes to 5GB ?
At the moment my log file is over 500GB.

/var/lib/postgres/

Best Answer

Have you tried setting log_rotation_size as described in http://www.postgresql.org/docs/9.1/static/runtime-config-logging.html#GUC-LOG-ROTATION-SIZE ? That would work if the log is managed directly by postgresql. If you are using syslog then you should look at newsyslog or logrotate.