Bug 431865
Summary: | anacron and crond both run cron.daily | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Jonathan Kamens <jik> |
Component: | anacron | Assignee: | Marcela Mašláňová <mmaslano> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | rawhide | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2008-03-27 10:15:40 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Jonathan Kamens
2008-02-07 14:57:55 UTC
Could you attach whole log from the "what happened this morning" (also the time before)? I was trying to solve this before. It should be working this was: If you don't reboot, only cron.daily will be run at 4:02. If you shut down your computer, then anacron run cron.daily, with 65 + delay ('uniq' for computer) minutes delay. It could be possible that you restarted computer in the middle of cron.daily process before the time stamp of process was created. It is obvious from the log excerpts shown above that I did not restart my computer in the middle of cron.daily. As the log excerpts shown, on my computer, cron.daily is run by crond at 3:03am, and as I said in the ticket, I rebooted at 1:45am. The problem is that anacron's logic for determining whether a day has elapsed since the last time the job was run is flawed. All it does is calculate the day number of the current day, subtract it from the day number the last time the job was run, and see if the difference is greater than or equal the desired frequency of the job. This is obviously the logic from looking at consider_job in lock.c in the anacron sources. In other words, between midnight and when crond runs the cron.daily, if the machine reboots then anacron will run the job and then crond will run it as well. This is wrong and dangerous when there are jobs that will break if they are run twice at the same time. The simplest solution is to subtract the two actual timestamps (current - last run) and determine if the resulting number of seconds / 60 / 60 / 24 + 60 exceeds the period of the job. That is, determine if the exact minute during which cron should have started the job and updated its timestamps has passed. Now, I read the log file twice and find out there's no problem ;-) > Feb 7 01:45:43 jik2 anacron[2861]: Anacron 2.3 started on 2008-02-07 > Feb 7 01:45:43 jik2 anacron[2861]: Will run job `cron.daily' in 65 min. > Feb 7 01:45:43 jik2 anacron[2861]: Will run job `cron.weekly' in 70 min. > Feb 7 01:45:43 jik2 anacron[2861]: Jobs will be executed sequentially > Feb 7 02:50:43 jik2 anacron[2861]: Job `cron.daily' started > Feb 7 02:50:43 jik2 run-parts(/etc/cron.daily)[10208]: starting 000-delay.cron Here's starting the first job in /etc/cron.daily, but as you can see there wasn't updated timestamp. So the cron jobs weren't done and they were run again. If you don't switch off your computer than the cron.daily will run at 4:02. If you reboot before 4:02 or switch off the computer, than the cron.daily will run after 65minutes. You can send me a patch with better solution, if the example in comment#2 is working well. I'd like to review it. |