FreePBX17 /var/log 96% full - how to clean this up?

I cannot find documentation for command to limit the size of this file

#df

Filesystem 1K-blocks Used Available Use% Mounted on
udev 8045592 0 8045592 0% /dev
tmpfs 1614596 1056 1613540 1% /run
/dev/mapper/pbxvg0-lvroot 2457952 1083288 1250560 47% /
/dev/mapper/pbxvg0-lvusr 13443376 2921824 9859484 23% /usr
tmpfs 8072964 324 8072640 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
/dev/sda2 965872 67504 831964 8% /boot
/dev/mapper/pbxvg0-lvhome 5071712 58888 4769856 2% /home
/dev/mapper/pbxvg0-lvsrv 5426040 28 5168628 1% /srv
/dev/mapper/pbxvg0-lvtmp 3245740 176 3076816 1% /tmp
/dev/mapper/pbxvg0-lvusrlocal 3113568 328 2949896 1% /usr/local
/dev/mapper/pbxvg0-lvvar 31332304 4249932 25640764 15% /var
/dev/mapper/pbxvg0-lvvarlog 51962564 47639996 2042448 96% /var/log
/dev/mapper/pbxvg0-lvvartmp 6019936 116 5710492 1% /var/tmp
/dev/mapper/pbxvg0-lvvarspool 332966132 1223088 316393204 1% /var/spool
/dev/sda1 997432 5984 991448 1% /boot/efi
/dev/mapper/pbxvg0-lvvarlogaudit 5890880 24 5586772 1% /var/log/audit
tmpfs 1614592 0 1614592 0% /run/user/1000

/var/log is a directory, not a file. It contains log files from a number of different things, many of them relating to the OS, rather than FreePBX.

Typically you run logrotate, from a cron script, but the details depend on the specific log file.

How much log file you keep is a policy decision depending on how far you need to go back in time to analyze a problem, and, again will depend on the particular log file.

Thanks for responding

You look in the directory and find which files are getting large, do a search to find out how important they are to you. If they are FreePBX related, come back here. If they are OS related, consult information on the OS.

Wish I knew how to look in the directory and list the files - I’m more of a Windose guy.

That is incorrect. The log files for both Asterisk and FreePBX are in /var/log/asterisk, which is the default logging path for Asterisk.

If the OP is confusing directories and files, I think they will have even more trouble with sub-directories. Only the files take up significant space, and the files in /var/log/asterisk will be included in

My real points were that the space is in the files, there is more than one file, not all of those files are the responsibility of FreePBX.

The offending file /dev/mapper/pbxvg0-lvvarlog is tripping email alerts. I understand that there is a way to configure the size of the file and how far back it will save the old log files (rotation). Is there a good reference to guide me through this, or can I ask what the line-by-line commands are so I can fix this?

There’s already a log rotation file if you did an official install of FreePBX v17. Are you saying a single file is getting too big? Because the directory space filling up just isn’t from the active log files there are the rotated log files as well. Outside of saying “My disk is getting full” you haven’t really shown/explained what is taking up the space or if there are rotated files.

root@fpbx17-dev:~# cat /etc/logrotate.d/asterisk 
/var/log/asterisk/queue_log {
        daily
        missingok
        rotate 30
        notifempty
        sharedscripts
        create 0640 asterisk asterisk
        su asterisk asterisk
        postrotate
                /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
        endscript
}

/var/spool/mail/asterisk {
        daily
        missingok
        rotate 7
        notifempty
        sharedscripts
        create 0660 asterisk mail
        su asterisk mail 
}

/var/log/asterisk/messages
/var/log/asterisk/event_log
/var/log/asterisk/full
/var/log/asterisk/dtmf
/var/log/asterisk/fail2ban {
        daily
        missingok
        rotate 7
        notifempty
        sharedscripts
        create 0640 asterisk asterisk
        su asterisk asterisk
        postrotate
                /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
        endscript
}

This isn’t a normal file either. It represents a disk partition, and is almost certainly of fixed size.

Basically the questions you are asking suggest you have no understanding of logging and filesystem structures, on Linux, and probably not, to the necessary detail, on Windows either. I think you need to hire someone with the appropriate knowledge (or present a case here as to why someone should do the work pro bono). Generally people providing free support are only interested in things that the requestor might reasonably have not known about, not in dealing with the basic debugging steps that anyone analyzing a problem needs to know.

Basically logs provide information that can help a manager to understand the way the system is operating (and may also capture information used for billing). Your statistics are only telling you that the total of all your log files is reaching the limit Either something has gone wrong with the measures used to remove old entries, or some events are occurring that are creating a lot of loggable events. In the latter case, you need to find the specific file that has become excessively large, not just the filesystem (which basically only tells you that you are dealing with a large log file) and look inside it. It will contain messages about those events. Most of the files will be plain text, or simply compressed plain text files, although newer Linux systems also have files that require a special tool (journalctl) to format them.

https://sangomakb.atlassian.net/wiki/spaces/SS/pages/31162494/Support+Services+-+Providing+Great+Debug has some information on how FreePBX and Asterisk use log files, and how they can be used for debugging, but your current symptoms aren’t enough to narrow the problem down to one due to FreePBX.

There is some information on handling the case where specifically Asterisk related log files become too large at Large FULL Log Files

In terms of a purely symptomatic approach, any normal file subordinate to /var/tmp which ends in .1, or .z, can be removed with no more risk than that you might destroy evidence of the root cause. Other normal files subordinate to it an be removed, but the removal might not be complete until the system is rebooted, and there is a risk that they will get recreated with the wrong ownership, or the recreation will fail.

Removing sub-directories may break logging until they are manually recreated, although some may get recreated if found to be missing.

I found on our installation a number of logfiles in /var/log/asterisk/ that were not in /etc/logrotate.d/asterisk to be rotated.

I would recommend you read up or ask someone to help that knows linux fairly well to set them up for how you want to retain those logfiles. I tweaked our config file to include those files that were not being rotated and it cleaned itself up overnight like it should.

Here is what I ended up with on our installation so far:

/var/log/asterisk/queue_log {
        daily
        missingok
        rotate 30
        notifempty
        sharedscripts
        create 0640 asterisk asterisk
        su asterisk asterisk
        postrotate
                /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
        endscript
}

/var/spool/mail/asterisk {
        daily
        missingok
        rotate 7
        notifempty
        sharedscripts
        create 0660 asterisk mail
        su asterisk mail
}
/var/log/asterisk/*.log
/var/log/asterisk/*.err
/var/log/asterisk/dpma
/var/log/asterisk/messages
/var/log/asterisk/sangomartapi
/var/log/asterisk/event_log
/var/log/asterisk/full
/var/log/asterisk/backup
/var/log/asterisk/errors {
        daily
        missingok
        rotate 7
        su asterisk asterisk
}
/var/log/asterisk/dtmf
/var/log/asterisk/fail2ban {
        daily
        missingok
        rotate 7
        compress
        notifempty
        sharedscripts
        create 0640 asterisk asterisk
        su asterisk asterisk
        postrotate
                /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
        endscript
}








And which files exactly weren’t in the logrotate file?

try this to find out the size of your /var/log directory:

du -xh --max-depth=1 /var/log |sort -h or your /var/log/asterisk

du -xh --max-depth=1 /var/log/asterisk |sort -h

In earlier times my most large files have been in /var/spool/asterisk, not in log

du -xh --max-depth=1 /var/spool/asterisk |sort -h

You will get an output similar to this one:

0 /var/spool/asterisk/backup
0 /var/spool/asterisk/confbridge
0 /var/spool/asterisk/fax
0 /var/spool/asterisk/incron
0 /var/spool/asterisk/meetme
0 /var/spool/asterisk/outgoing
0 /var/spool/asterisk/pms
0 /var/spool/asterisk/system
12K /var/spool/asterisk/sysadmin
364K /var/spool/asterisk/cache
57M /var/spool/asterisk/voicemail
1.1G /var/spool/asterisk/tmp
136G /var/spool/asterisk/monitor
137G /var/spool/asterisk

which shows the consumption of file sizes

Depending on this information you can work on.

InBlazeStudios answer you keep files e.g for 30 days. You may reduce the logrotate config to keep the logfiles for 7 days only. Your decision.

Only the queue log is kept for 30 days. Every other logfile is kept for 7 days.

That work would make for some nice first issue diffs in our GitHub repos… modules have hooks for logrotate actions, primarily to add configuration files in to the /etc/logrotate.d/ directory, e.g.

Uhm..you really should be checking everything in the logrotate directory. Commercial modules will make their own logrotate

-rw-r--r--   1 root root   148 Nov  2 15:09 freepbx-api
-rw-r--r--   1 root root   205 Nov  2 15:09 freepbx-cdrpro
-rw-r--r--   1 root root   581 Nov  2 15:09 freepbx-core
-rw-r--r--   1 root root   146 Nov 11 15:44 freepbx-fwJOB
-rw-r--r--   1 root root   211 Nov  2 15:11 freepbx-qcallback
-rw-r--r--   1 root root   542 Nov  2 15:10 freepbx-restapps
-rw-r--r--   1 root root   149 Nov  2 15:10 freepbx-sangomacrm
-rw-r--r--   1 root root   235 Nov 11 15:45 freepbx-ucp
-rw-r--r--   1 root root   274 Nov  2 15:09 oc_logrotate
-rw-r--r--   1 root root   142 Nov  2 15:11 openvpn
-rw-r--r--   1 root root   181 Nov  2 15:10 pms
-rw-r--r--   1 root root   372 Jan  1  2025 queuestats
-rw-r--r--   1 root root   683 Nov  2 15:10 sangomaconnect
-rw-r--r--   1 root root   486 Nov  2 15:10 sangomartapi

So you added a bunch of stuff to the general Asterisk/FreePBX rotate config that already exists with their own configs.

May or may not be related, but in general you should go into the log settings on FreePBX and disable debug and verbose. For some reason that is still the default on a new install. It should not be imo.

Debug should normally be off, as most system managers won’t be able to use it effectively, but verbose comes in multiple levels, and I’d certainly want it partially enabled.