Log rotation not working

I have VitalPBX installed for over 4 years now. Current version: v3.2.3-4 (latest download is now is: v3.2.2-1), so I am pretty up-to-date :grinning:

For some months, I have noticed that my VitalPBX VPS was running out of disk space.
The culprit seems to be the logfiles not automatically being deleted (log rotation not working).
In /etc/logrotate.d/ the file asterisk has the following content:

As you can see, the logfiles like /var/log/asterisk/full and /var/log/asterisk/fail2ban, should be rotating daily and I believe rotate 2 means that only the 2 latest log files of each log should be kept for archive purpuses.
However as shown below, the rotate does not seems to work, becaue I have a total of 6 fail2ban [1] files and 18 full [2] file. At [3] you see full-20211120.gz which suggest that “full” log files used to get compressed in the past.

I have the following questions:

  1. Does anyone knows away to get the rotation working again on my VitalPBX installation ?
  2. Could I withould any penalty add compress and compressdelay to the log daemon, to atleast gett the lofgiles make the archived logfiles smaller ?

It looks like the problem I am having, might be related to the message from @PitzKey at Log file "full" is missing - #5 by mo10 which supposedly was fixed in VitalPBX v3.1.3.
The change logs do mention a fix “Asterisk: in some circumstances, the log files didn’t get deleted automatically.” in VitalBPX v3.2.3 R2 (August 14, 2022), however my cuurent version is: v3.2.3-4.

rotate 2 - This specifies the number of times to rotate a file before it is deleted. A count of 0 (zero) means no copies are retained. A count of 2 means five copies are retained.

My theory is that daily and size does not go well together.
I’m not sure what the point of size is here. Why not rotate daily regardless of the size?

Screenshot of yours please:

Size might be an issue, however it seems that the logs DO switch at about 1GB or about every 6/7 days.
I am gonna add “compress” and “delayedcompress” to the logrotate, remove the “size 5GB” and makes the log rotate at 7 days. Just to see the rotation will start working.

Would you care to eleborate on the this ?
At the moment I am using WinSCP to access my Vitalpbx.
Not being a Linux man, I have brush up my knowledge, to see how I can access my machine via command line.

As of today this my rotate script:
I gonna monitor this comming week to see if the rotation will start rotating and deleting logfiles on a daily basis.

Just go via ssh to that folder and run that command.
Then provide screenshot if the outcome.

Got the following screenshot for you:

/etc/logrotate.d$ logrotate -vd /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file asterisk
reading config file bootlog
reading config file chrony
reading config file fail2ban
reading config file firewalld
reading config file httpd
reading config file mysql
reading config file php-fpm
reading config file syslog
reading config file vitalpbx
reading config file wpa_supplicant
reading config file yum
Allocating hash table for state file, size 15360 B

Handling 17 logs

rotating pattern: /var/log/asterisk/messages
/var/log/asterisk/fail2ban  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 995 and egid to 992
considering log /var/log/asterisk/messages
  log /var/log/asterisk/messages does not exist -- skipping
considering log /var/log/asterisk/event_log
  log /var/log/asterisk/event_log does not exist -- skipping
considering log /var/log/asterisk/full
  log needs rotating
considering log /var/log/asterisk/dtmf
  log /var/log/asterisk/dtmf does not exist -- skipping
considering log /var/log/asterisk/fail2ban
  log needs rotating
rotating log /var/log/asterisk/full, log->rotateCount is 7
dateext suffix '-20221003'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
rotating log /var/log/asterisk/fail2ban, log->rotateCount is 7
dateext suffix '-20221003'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
renaming /var/log/asterisk/full to /var/log/asterisk/full-20221003
creating new /var/log/asterisk/full mode = 0640 uid = 995 gid = 992
renaming /var/log/asterisk/fail2ban to /var/log/asterisk/fail2ban-20221003
creating new /var/log/asterisk/fail2ban mode = 0640 uid = 995 gid = 992
running postrotate script
running script with arg /var/log/asterisk/messages
/var/log/asterisk/fail2ban : "
                /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
switching euid to 0 and egid to 0

Just did a command line: logrotate -vd /etc/logrotate.conf
With the above resulted (kept only the part of relefvant logs like full and fail2ban).

Using the -d switch did a fake rotation, but it indicate that or FULL and FAIL2BAN, it is considering log rotation.
Could it be that some how the log rotation/executing the script is not triggered anymore ?

Some update about my VitalPBX log rotation:
I see the compression went at about 05:58 AM which is about (UTC - 6h).
I am a little disappointed though because no (older) logs were deleted.



It has been a couple of days, the fail2ban and full log are getting compressed daily now, however despite being more than 7 logs of each, the older logs are not getting deleted.

Besides manually deleting the old logs, does anyone has am idea how to trigger the deletion of the older logs automatically ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.