Logrotate execution time

Dear all: my FreePBX Distro is executing logrotate at 3:11am and I can’t figure out how to change it, as it sounds more logical, to me at least, to have logrotate run at 0:00, so each logfile contains data for one day only. I read everywhere but couldn’t find how to modify the time when logrotate runs, I checked crontab but I don’t see an entry related to logrotate, at leats not from the names of the scripts. My asterisk logrotate configuration and crontab contents are below, I appreciate any help that you can provide.

[root@freepbx logrotate.d]# cat asterisk
/var/log/asterisk/queue_log {
daily
missingok
rotate 7
notifempty
sharedscripts
create 0640 asterisk asterisk
}

/var/log/asterisk/freepbx_dbug{
size 500M
missingok
rotate 7
notifempty
sharedscripts
create 0640 asterisk asterisk
}

/var/log/asterisk/prosody_debug.log
/var/log/asterisk/prosody.log
/var/log/asterisk/ucp_err.log
/var/log/asterisk/ucp_forever.log
/var/log/asterisk/ucp_out.log
/var/log/asterisk/freepbx_debug
/var/log/asterisk/freepbx.log {
daily
missingok
rotate 7
notifempty
create 0640 asterisk asterisk
}

/var/log/asterisk/freepbx_security.log {
size 100M
missingok
rotate 7
notifempty
sharedscripts
create 0640 asterisk asterisk
}

/var/spool/mail/asterisk
/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
postrotate
/usr/sbin/asterisk -rx ‘logger reload’ > /dev/null 2> /dev/null
endscript
}
#This comment is to fix rpm file replacing
#Config file built on Fri Jul 22 22:35:02 UTC 2016

[asterisk@freepbx ~]$ crontab -l
20 * * * * /var/lib/asterisk/bin/freepbx-cron-scheduler.php
@daily [ -e /var/www/html/admin/modules/sysadmin/bin/check_portal.php ] && /var/www/html/admin/modules/sysadmin/bin/check_portal.php
@daily [ -x /var/lib/asterisk/bin/freepbx_sipstation_check ] && /var/lib/asterisk/bin/freepbx_sipstation_check

          • [ -x /var/www/html/admin/modules/dashboard/scheduler.php ] && /var/www/html/admin/modules/dashboard/scheduler.php
            @monthly ID=freepbx_backup_1 /var/lib/asterisk/bin/backup.php --id=1
            @daily [ -x /var/lib/asterisk/agi-bin/ddns_client.php ] && /var/lib/asterisk/agi-bin/ddns_client.php
            @hourly [ -x /var/lib/asterisk/bin/storage.php ] && /var/lib/asterisk/bin/storage.php
            30 * * * * /usr/sbin/fwconsole util cleanplaybackcache -q
  • 3 * * * /usr/sbin/fwconsole certificates updateall -q
    @daily [ -x /var/lib/asterisk/agi-bin/update_license.php ] && /var/lib/asterisk/agi-bin/update_license.php --delay
          • [ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php

It probably depends :wink: if someone runs backups about midnight or 1AM, they may need time for the backup operations to finish, and logrotate to not get in the way.

I see your point and it seems valid, but I would still like the log to rotate at 00:00 instead of 03:11. Do you happen to know how to make that happen?

look in /etc/anacrontab
(e.g. mine has

# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

but if you change that, ALL the scripts in cron.daily will be ran at midnight;
This advice is actually for ubuntu but see http://askubuntu.com/questions/24503/specify-the-time-of-daily-log-rotate, the part with moving logrotate.cron to another directory and creating crontab entry for it only.)

Thanks el_es. I found that file and edited it to make it rotate at 00:00. Thanks again.