This article provides provide information to help rotate the logfile when the database is up and running.
Note- Please verify the script on a test cluster , before running it on production .
Function "pg_rotate_logfile" is a handy little tool to rotate the database log when the database is up and running.
Below example helps you understand the function "pg_rotate_logfile" in practice.
flightdata=# select pg_ls_dir('pg_log') order by 1 desc; pg_ls_dir ---------------------------- startup.log gp_era gpdb-2013-04-22_131246.csv gpdb-2013-04-22_000000.csv [.....] [.....] Use pg_rotate_logfile to switch logfile and write to a new logfile flightdata=# select pg_rotate_logfile(); pg_rotate_logfile ------------------- t (1 row)
flightdata=# select pg_ls_dir('pg_log') order by 1 desc; pg_ls_dir ---------------------------- startup.log gp_era gpdb-2013-04-22_131722.csv gpdb-2013-04-22_131246.csv gpdb-2013-04-22_000000.csv [.....] [.....]Alternatively, you can use/tune parameter "log_rotation_size" to rotate the logfile when they reach a certain size , by default the size is zero which means all the contents remain on a single file.
Pivotal Greenplum Database (GPDB) all versions