===== How to change CUPS logrotate schedule =====
CUPS logrotate is configured in ''/etc/logrotate.d/cups-daemon''. By default, logrotate is performed daily, and after the rotate CUPS is restarted.
/var/log/cups/*log {
daily
missingok
rotate 7
sharedscripts
postrotate
invoke-rc.d --quiet cups restart > /dev/null
endscript
compress
delaycompress
notifempty
create
}
By default, the installation of logrotate creates a crontab file inside ''/etc/cron.daily'' named ''logrotate''. As it is the case with the other crontab files inside this directory, it will be executed daily starting at ''6:25 am'' if anacron is **not** installed. Otherwise, the execution will begin around ''7:35 am''. To verify, watch for the line containing ''cron.daily'' in either ''/etc/crontab'' or ''/etc/anacrontab''.
//How does this happen?//
Taking Ubuntu 16.04 defaults as example:
...
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
...
> If anacron exists, ''test -x /usr/sbin/anacron'' will return true, and prevent the second half of that line from running: in that case ''/etc/cron.d/anacron'' must be edited to change daily scheduled time, since that's the config that will kick off anacron itself.
30 7 * * * root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
> anacron is started at ''7:30 am'', but hang on ... the actual anacron behavior is configured in ''/etc/anacrontab''
...
# These replace cron's entries
# 1 = daily, 5 = number of minutes anacron waits, before executing the job.
1 5 cron.daily run-parts --report /etc/cron.daily
...
> So, effectively, CUPS daily logrotate is kicked off at ''7:30 am'' by anacron, but the actual rotate is executed after a 5 minutes wait, at ''7:35 am'' (( See [[https://www.linux.org/docs/man5/anacrontab.html|anacron manpage]] )).
==== anacron: logrotate daily at 6:35am ====
sudo vi /etc/cron.d/anacron
... and change line like this:
30 6 * * * root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start
==== Change time interval ====
[[https://www.linux.org/docs/man5/logrotate.html|man logrotate]]
sudo vi /etc/logrotate.d/cups-daemon
# change daily to weekly, monthly, yearly