UCP logs not rotating, filling up hard disk

Started getting notifications over the weekend that one VM is 79% full. I found some old backups that were stored locally on the machine which cleared up 5 GB or so but I see that the three UCP logs are massive (1-4 GB each). Pardon my ignorance but where can I set the rotation settings for those? I did a little reading on the logrotate function in Linux but don’t see much of anything in the /etc/logrotate.conf file. I checked the various cron files and they also just point at the logrotate.conf file. So where are these settings stored?

FreePBX 13.0.190.19
PBX Firmware:10.13.66-19

I found a directory /etc/logrotate.d and I added these three lines to the portion of the asterisk file that lists some of the logs in the /var/log/asterisk directory and tried to make the pbx run the script logrotate -f /etc/logrotate.d/asterisk

/var/log/asterisk/ucp_err.log
/var/log/asterisk/ucp_forever.log
/var/log/asterisk/ucp_out.log

This at the very least seems to have rotated the logs so I’ll just delete the old ones and be done with it.

So the file now has

/var/spool/mail/asterisk
/var/log/asterisk/messages
/var/log/asterisk/event_log
/var/log/asterisk/full
/var/log/asterisk/dtmf
**/var/log/asterisk/ucp_err.log**
**/var/log/asterisk/ucp_forever.log**
**/var/log/asterisk/ucp_out.log**
/var/log/asterisk/fail2ban {
daily
missingok
rotate 7
notifempty
sharedscripts
create 0640 asterisk asterisk
postrotate
/usr/sbin/asterisk -rx ‘logger reload’ > /dev/null 2> /dev/null
endscript
}

Probably should have downloaded those logs and looked at them before deleting them because obviously something was going on with UCP on that PBX but for now it’s staying empty. I checked a couple of PBXs that have been running for years and they have practically nothing in those log files. Will check back if the logs start to fill up again.

This is wrong and won’t work.

The logrotate files are added by each module. Look in the hooks folder of ucpnode.

Interesting. It looks like its set to rotate when it hits 100 MB (if I’m reading that right) but it certainly wasn’t doing that since it was in the GB range. Also, looking at my two screen shots I can see that in the 40 minutes between the pictures the logs grew by a MB worth of content, which is quite a bit…

Here’s whats in that file currently, and it doesn’t seem to work. All it does is paste the code into this new file called freepbx-ucpnode

#!/bin/bash

if true ; then
	cat <<- EOF > /etc/logrotate.d/freepbx-ucpnode
	/var/log/asterisk/ucp_err.log
	/var/log/asterisk/ucp_forever.log
	/var/log/asterisk/ucp_out.log{
		size 100M
		missingok
		rotate 7
		notifempty
		sharedscripts
		create 0640 asterisk asterisk
	}
	EOF
fi

That is not what is in the file. I think you should update. The real file has: (Just verified from online) and if I am correct you are reporting an issue that is months old and was resolved months ago

#!/bin/bash

if true ; then
	cat <<- EOF > /etc/logrotate.d/freepbx-ucpnode
	/var/log/asterisk/ucp_err.log
	/var/log/asterisk/ucp_out.log{
		size 50M
		missingok
		rotate 5
		notifempty
		sharedscripts
		create 0640 asterisk asterisk
		postrotate
		/usr/sbin/fwconsole pm2 --reload-logs -q
		endscript
	}
	EOF
fi

Months? Am I that far behind? This PBX is .19 and the updater only mentions .20.

And I don’t understand what this script is supposed to do. I copied and pasted what you have into mine (really just removing the one log, adding the three lines at the end, and changing the two parameters) and all this seems to do is copy that code into /etc/logrotate.d/freepbx-ucpnode

I tried pasting a bunch of stuff into the ucp_err.log to get it over the threshold ( I turned the threshold down to 1 mb) and I don’t see anything happening when I do a ./logrotate

use

logrotate -f -v /etc/logrotate.conf

to see what is working or not. The -f will “force” the rotation even if not due the -v will “be verbose” as to what logrotate is doing

It says it didn’t need rotating but it did rotate it so I guess I’m OK with that.

considering log /var/log/asterisk/ucp_err.log
log does not need rotating
considering log /var/log/asterisk/ucp_forever.log
log does not need rotating
considering log /var/log/asterisk/ucp_out.log
log does not need rotating

Now you halpove to figure out the “forever.log” but . . . .

If you update your freepbx modules this would be resolved automatically.