I am trying to run may logrotator using following anacron setup to run it at 11:59 PM as daily task.
My current setting for /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=0
# the jobs will be started during the following hours only
START_HOURS_RANGE=23-23
#period in days delay in minutes job-identifier command
1 59 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly
but this is not working. May be reason is START_HOURS_RANGE=23-23 that is not valid range. Is there any way that I can set it up so that it will run every day at exactly 11:59 PM? (if server running)
Last anacron daily running time is (var/spool/anacron/cron.daily )
20180322
my cron log
run-parts(/etc/cron.hourly)[31456]: starting 0anacron
Mar 27 11:01:01 ********[31467]: Anacron started on 2018-03-27
Mar 27 11:01:01 ******** anacron[31467]: Normal exit (0 jobs run)
Any kind of help is appreciable. Thanks
Best Answer
Your requirement for this job to be run every day at exactly 11:59 PM if server running suggest strongly that you are using Anarcon for something you should actually be using Cron for, instead. Anacron is designed to run jobs daily regardless of the hours the machine is on, while your goal is to run them at fixed minute. For that, a simple cronjob would do the trick: