Anacron START_HOURS_RANGE not respected

Kernels & Hardware, configuring network, installing services

Anacron START_HOURS_RANGE not respected

Postby debidant » 2018-10-30 15:03

On Stretch the START_HOURS_RANGE in my anacrontab ist not respected.

This is my configuration:
Code: Select all
dpkg -l|grep cron
ii  anacron                                 2.3-24                                      amd64        cron-like program that doesn't go by time
ii  cron                                    3.0pl1-128+deb9u1                           amd64        process scheduling daemon


Code: Select all
cat /etc/cron.d/anacron
# /etc/cron.d/anacron: crontab entries for the anacron package

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

30 7    * * *   root   [ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi



Code: Select all
cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user   command
17 *   * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6   * * *   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6   * * 7   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6   1 * *   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )



Code: Select all
cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root
START_HOURS_RANGE=11-20

# These replace cron's entries
1   5   cron.daily   run-parts --report /etc/cron.daily
7   10   cron.weekly   run-parts --report /etc/cron.weekly
@monthly   15   cron.monthly   run-parts --report /etc/cron.monthly


I assume it has something to do with systemd but I don't get it. Problem is that my Backup starts right at midnight where I'm still working sometimes. So I cannot suspend my computer as the backup is running several hours.

Thanks.
debidant
 
Posts: 25
Joined: 2016-10-27 13:23

Re: Anacron START_HOURS_RANGE not respected

Postby bw123 » 2018-10-30 23:07

Not sure what the problem would be, are you running the backup from cron.daily? Have you thought about using a systemd timer instead?

-or- what about removing anacron, or stopping it and just using cron, if you are sure the machine will be up when the task needs to run?

If you try to delay anacron, or set it's specific time to run cron jobs, then might it be more likely you will miss a timeframe that the backup gets done? anacron is supposed to make sure it gets cron done, so I'd say it is working as expected?

what about suspend the computer in the script that performs the backup after it is done if you're not working? sounds complicated.
User avatar
bw123
 
Posts: 3531
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Anacron START_HOURS_RANGE not respected

Postby debidant » 2018-10-31 06:26

bw123 wrote:Not sure what the problem would be,

(1) are you running the backup from cron.daily?

(2) Have you thought about using a systemd timer instead?

(3) -or- what about removing anacron, or stopping it and just using cron, if you are sure the machine will be up when the task needs to run?

(4) If you try to delay anacron, or set it's specific time to run cron jobs, then might it be more likely you will miss a timeframe that the backup gets done? anacron is supposed to make sure it gets cron done, so I'd say it is working as expected?

(5) what about suspend the computer in the script that performs the backup after it is done if you're not working? sounds complicated.


Thanks for your suggestions,

(1) yes

(2) no as anacron shoulndn't make this necessary

(3) problem is: I'm not sure the machine will be up

(4) sadly it's not. If it would work as expected it would respect the constraints i make to it

(5) sadly not possible as sometimes I let the machine do complex calculations during the night.

Any ideas?

Thanks.
debidant
 
Posts: 25
Joined: 2016-10-27 13:23

Re: Anacron START_HOURS_RANGE not respected

Postby bw123 » 2018-10-31 13:33

I would search for documentation, where is the setting documented?

/usr/share/doc/anacron/README.gz
...
What Anacron is not ?
---------------------

Anacron is not an attempt to make cron redundant. It cannot
currently be used to schedule commands at intervals smaller than days.
It also does not guarantee that the commands will be executed at any
specific day or hour.
...

I see you already have a thread started for this, please don;t do this. Cross-posting is really a bad idea if you want to solve problems, it make it look likeyou are whining, or trying to be disruptive.
viewtopic.php?f=5&t=134367

Another thread I found may be relevant, suggests that START_HOURS_RANGE is either distro-specific, or supported on a later ver of anacrontab. When in doubt, I prefer debian documentation (man page or /usr/share/doc)
https://askubuntu.com/questions/316706/ ... or-anacron
User avatar
bw123
 
Posts: 3531
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Anacron START_HOURS_RANGE not respected

Postby debidant » 2018-10-31 16:55

Sorry for the double post. I was in a hurry and hadn't remembered the previous post of last year. This was not by intention.

But you enlightend me in another way:
I just found out of the package systemd-cron which does exactly what I want (at least according to the docs).
I will report back if it works as promised!
debidant
 
Posts: 25
Joined: 2016-10-27 13:23

Re: Anacron START_HOURS_RANGE not respected

Postby pylkko » 2018-11-01 11:54

I don't know why you would not want to use a timer unit for this as it would so nicely solve all of your problems. If I understand properly, the issue is that you want to run a back up, but you also want it to be run in case the computer is off or suspended, and you want the machine to suspend after it has done the job at night (but only if you are not also running a calculation)

a timer unit can be set to run a job at a specific time, or immediately after that time if the machine was off with the Persistent setting. A timer can even be set to wake the system and perform the job with the WakeSystem setting. OnUnitActiveSec can be used to suspend the computer after a job is over. You can uses systemd-inhibit to make sure your calculation process prevents suspension and suspension is allowed after calculation process exits.
User avatar
pylkko
 
Posts: 1353
Joined: 2014-11-06 19:02


Return to System configuration

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable