docker-freepbx
docker-freepbx copied to clipboard
logrotate does not run daily
In FreePBX -> Settings -> Asterisk Logfile Settings, you can configure log rotation. I believe this uses logrotate, as it appears to configure it in /etc/logrotate.d/asterisk
. Running logrotate /etc/logrotate.conf -v -f
inside the container rotates the asterisk logs as expected. However, I think the container is missing a service to run this daily.
Looking at /lib/systemd/system/
, there is logrotate.service
and logrotate.timer
, which suggests there should be something similar in /etc/init.d
, but I am not seeing it. On my host OS (Ubuntu Server 20.04), I also see a cron job at /etc/cron.daily/logrotate
with the following:
$ cat /etc/cron.daily/logrotate
#!/bin/sh
# skip in favour of systemd timer
if [ -d /run/systemd/system ]; then
exit 0
fi
# this cronjob persists removals (but not purges)
if [ ! -x /usr/sbin/logrotate ]; then
exit 0
fi
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit $EXITVALUE
I am not completely sure what the solution is here, but I think it involves either adding an init.d service for logrotate with a timer or a daily cron job.
Update: I believe this is now working with the following envs set:
- "ENABLE_LOGROTATE=TRUE"
- "ENABLE_CRON=TRUE"