Logrotate creates long names and does not delete logs

The other answers here are correct, you need to change what files are being matched by your config. The same problem could occur with the files in /var/log, but the combination of compression and the 10M size limit is keeping it from happening.

There's another problem you're going to run into that I'd like to point out. Logrotate is built to rely on a consistent log file name to rotate out old files. When it processes a log file, it uses that as a base name to find all old versions of it by searching for the specific extension that old versions would have. That's what the glob stuff in your debug log is looking for. Since your filename changes every time because of the date, it will never go back and look at those old ones because the filename it's working on now doesn't match.

There's two things you could do. First option would be to set up postgres or whatever script is creating that dump file to not use the date. Keeping the filename consistent will let logrotate do it's thing and clear out the old ones. Alternatively, you could skip logrotate entirely and put something like this in your crontab:

0 4 * * * find /var/backup/postgres/postgres_db_dump_*.gz -mtime +10 -delete

That would run every night and delete the dump files that are older than 10 days.


/var/log/* {
    size=10M
    postrotate 
        /usr/bin/killall -HUP syslog-ng
    endscript
}

The /var/log/* is your problem. That's matching all the files in /var/log, including the already-compressed files. You'll need to refine that glob matching pattern to only match the non-compressed files.


The manpage for logrotate says

   Please  use wildcards with caution.  If you specify *, logrotate will rotate all files,
   including previously rotated ones.  A way around this is to use the olddir directive or
   a more exact wildcard (such as *.log).