Rotating PostgreSQL's postmaster.log

By chimo on (updated on )

Similar to my `signal-desktop` container a while ago, I noticed my `postgresql` container was taking a while to backup. So of course the first I checked was the /tmp directory:

root@postgresql # du -chs /tmp
8.0K    /tmp/
8.0K    total

No issues here.

Onto the next typical culprit:

root@postgresql # du -chs /var/log/
80.0K   /var/log/messages
204.0K  /var/log/messages.0
7.2G    /var/log/postgresql
0       /var/log/wtmp
7.2G    total
root@postgresql # ls -lh /var/log/postgresql/
total 7.2G
-rw-------    1 postgres postgres       7.2G Nov  8 13:46 postmaster.log

Yeah, a 7GB logfile will do that.

So I enabled log rotation in PostgreSQL’s config file:

/etc/postgresql/postgresql.conf
logging_collector = on
log_directory = '/var/log/postgresql'

The rotation defaults are:

/etc/postgresql/postgresql.conf
log_rotation_age = 1
log_rotation_size = 10MB

Reply by email