Rotating freepbx related logfiles

At the moment, on FreePBX16, I’m rotating only asterisk logs.

/var/log/asterisk/debug
/var/log/asterisk/messages
/var/log/asterisk/full
/var/log/asterisk/*_log {
        weekly
        missingok
        rotate 6
        sharedscripts
        create 0640 asterisk asterisk
        su asterisk asterisk
        postrotate
                /usr/sbin/invoke-rc.d asterisk logger-reload > /dev/null 2> /dev/null
        endscript
}

Does the same postrotate commands cover rotating these files:

/var/log/asterisk/freepbx.log
/var/log/asterisk/freepbx_dbug
/var/log/asterisk/freepbx_security.log
/var/log/asterisk/backup.log

and what about node processes’ logs

/var/log/core-*.log

Many thanks

No. It only covers files written by Asterisk. I don’t know how FreePBX writes its log files. It may open and close them every time it writes, in which case no postrotate command would be needed.

1 Like

Thanks @david55. Since posting, I found some logrotate snippets that suggest the same. So I’ll try rotating those without any command.

Regarding the /var/log/core-*.log. AIUI those files are associated with PM2 and on my system seem to be held open for writing. So I am guessing it is not OK simply to rotate those. There is however fwconsole pm2 --restart. May be I could/should use that?

I’d expect files called core* to be crash dump files and not held open.

Sorry, I made a typo in the path. The actual files are these:

root@pbx:~# lsof /var/log/asterisk/core-*
COMMAND PID     USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
node    702 asterisk   21w   REG 252,25     5921 951654 /var/log/asterisk/core-calltransfer-monitor_out.log
node    702 asterisk   22w   REG 252,25        0 951644 /var/log/asterisk/core-calltransfer-monitor_err.log
node    702 asterisk   26w   REG 252,25  1866020 951645 /var/log/asterisk/core-fastagi_out.log
node    702 asterisk   28w   REG 252,25        0 951640 /var/log/asterisk/core-fastagi_err.log