PostgreSQL will stop logging when logrotate rotate postgresql log file
1
vote
5
answers
6117
views
I have installed
PostgreSQL 10.6 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit
And configured:
log_filename = 'postgresql.log'
But I would like to manage log rotations by logrotate instead of internal logrotation by PostgreSQL:
#vim /etc/logrotate.d/postgresql
/var/lib/pgsql/data/log/postgresql.log {
daily
rotate 7
compress
create 0664 postgres postgres
missingok
notifempty
sharedscripts
}
Where logrotate works as expected but PostgreSQL will stop logging into the rotated
/var/lib/pgsql/data/log/postgresql.log
file. The only resolution is to systemctl restart postgresql
which could be placed inside logrotate postrotate/endscript
block but I can't do it this way if this is done on critical production system.
Do you have any advice how to properly logrotate PostgreSQL log file without need of restarting PostgreSQL?
Thanks!
**UPDATE:**
During reloading of PostgreSQL it looks for changes. I found a workaround how to achieve that PostgreSQL will start to log into rotated *postgresql.log* file - I need to modify config file, for example comment out/modify *log_filename* then reload PostgreSQL and revert changes back and reload PostgreSQL again. Because PostgreSQL looks for changes in configuration file. But I would be glad if there is another better solution than touching configuration file.
Asked by MyKE
(121 rep)
Oct 23, 2019, 01:10 PM
Last activity: Feb 25, 2025, 11:29 PM
Last activity: Feb 25, 2025, 11:29 PM