Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2412  / 3 Years ago, mon, june 7, 2021, 8:57:53

I am using Ubuntu 12.04 for an embedded project.
I need cron jobs to execute only at their specified time, because time may be stepped forwards (resulting in a missed job) but those jobs should be skipped.
While testing this, even when I place my crontabs into /etc/cron.d, and for example schedule the job for 13:15, set system time to 13:25, the job will execute at ~13:26.
I do not want to execute missed jobs, they should be ignored (according to the research I've done, this is "normal" cron behavior).
Any suggestions on how to remove anacron and just keep plain old cron?



Thanks.


More From » uninstall

 Answers
7

I see no reason why removing anacron would be problematic. The answer mentioned by papukaija doesn't contain any warnings either. Especially since missing jobs is exactly what you want when time is stepped.



The package description says:




You should install this program if your system isn't
powered on 24 hours a day to make sure the maintenance jobs of other
Debian packages are executed each day.




So simply remove it with sudo apt-get remove anacron (Don't use purge so the config files are kept)



One problem remains (as you noticed) - cron sees time steps smaller than three hours as results from something like Daylight Saving Time and still executes missed jobs.




Special considerations exist when the clock is changed by less than 3 hours, for example at the beginning and end of daylight savings
time. If the time has moved forwards, those jobs which would have run in the time that was skipped will be run soon after the change.
Conversely, if the time has moved backwards by less than 3 hours, those jobs that fall into the repeated time will not be re-run.



Clock changes of more than 3 hours are considered to be corrections to the clock, and the new time is used immediately




Your possible way around lies in the fact that only jobs with exact execution time are affected.




Only jobs that run at a particular time (not specified as @hourly, nor with '*' in the hour or minute specifier) are affected. Jobs which
are specified with wildcards are run based on the new time immediately.




So if you want to execute some job every 3 hours
you would write a line like



25  */3 * * * root /path/so/some/file





A completely different approach (if you want those jobs run at most once) would be to employ at.


[#30368] Wednesday, June 9, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ithriv

Total Points: 46
Total Questions: 115
Total Answers: 96

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;