vCenter Server vPostgres log rotation fails after 30 days due to date format
search cancel

vCenter Server vPostgres log rotation fails after 30 days due to date format

book

Article ID: 324290

calendar_today

Updated On: 05-18-2025

Products

VMware vCenter Server 7.0 VMware vCenter Server 8.0

Issue/Introduction

Symptoms:


Logs stop rotating for the following logs after 30 days:

  • /var/log/vmware/vpostgres/postgresql.log
  • /var/log/vmware/vtsdb/postgresql.log

/storage/log partition will be 100% full.

Cause

After 30 days log rotation will stop for the /var/log/vmware/vpostgres/postgresql.log and /var/log/vmware/vtsdb/postgresql.log due to the date format only including the day in the rotated log file name causing log rotate errors when it tries to create a new archive with the same name.

This leads to log files to stop being rotated and eventually fill up the /storage/log partition.

Resolution

Workaround:


Delete the old postgresql.log-0#.gz log files and it will continue rotating.

If it does not continue rotating, 

Update /etc/logrotate.d/vmware_postgres_log to this,
 

/var/log/vmware/vpostgres/postgresql.log {
   firstaction
      dim=$(date -d "$(date +%Y-%m-01) +1 month -1 day" +%d)
      find /var/log/vmware/vpostgres/ -name "postgresql.log-*gz" -mtime +$dim -exec rm {} \;
   endscript
   daily
   rotate 30
   maxage 30

   dateext
   dateyesterday
   dateformat -%Y-%m-%d_%H:%M:%S
   compress
   copytruncate
}


Update /etc/logrotate.d/vmware_vtsdb_postgres_log to this,   ( This file can be found on VCSA 8.x only)
 

/var/log/vmware/vtsdb/postgresql.log {
   firstaction
      dim=$(date -d "$(date +%Y-%m-01) +1 month -1 day" +%d)
      find /var/log/vmware/vtsdb/ -name "postgresql.log-*gz" -mtime +$dim -exec rm {} \;
   endscript
   daily
   rotate 30
   maxage 30

   dateext
   dateyesterday
   dateformat -%Y-%m-%d_%H:%M:%S
   compress
   copytruncate
}

 

No other action should be needed as the cron job will run every hour.