Deleting old postgresql log files (Ubuntu)

You can use the configuration below;

log_truncate_on_rotation = on
log_rotation_age = 1d
log_filename = 'postgresql-%a.log'
log_rotation_size = 0  #just rotate daily

This says create a log file with a name like 'postgresql-Mon.log' and when rotation occurs override the old file with the same name.


PostgreSQL supports log rotation feature but doesn't support log removing feature. So user should remove logs manually or has to use logrotate utility to remove them.

Here is the official document.