docker-freepbx icon indicating copy to clipboard operation
docker-freepbx copied to clipboard

logrotate does not run daily

Open leorg99 opened this issue 3 years ago • 1 comments

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.

leorg99 avatar Apr 25 '21 06:04 leorg99

Update: I believe this is now working with the following envs set:

      - "ENABLE_LOGROTATE=TRUE"
      - "ENABLE_CRON=TRUE"

leorg99 avatar May 25 '21 17:05 leorg99