Odd locate behavior
Little Girl
littlergirl at gmail.com
Mon Sep 16 14:16:46 UTC 2024
Hey there,
Chris Green wrote:
>Little Girl wrote:
>> It should run automatically every day, but a known weakness of cron
>> is that if the computer isn't running at a cron job's scheduled
>> time, it won't fire even when the computer is later turned on. If
>> you shut down your computer, like I do every night, there may be
>> cron jobs that aren't firing.
>That shouldn't be true for jobs run by anacron, that's the whole
>point of anacron. It's run at system boot time to check if there
>were any jobs that should have been run when the system was turned
>off.
I checked the /etc/anacrontab file and you're right that anacron is
set to run daily. However, this is what it says in the anacron man
page:
"For each job, Anacron checks whether this job has been
executed in the last n days, where n is the period specified
for that job. If not, Anacron runs the job's shell command,
after waiting for the number of minutes specified as the
delay parameter."
I could be interpreting that incorrectly, but here's my take on it:
If anacron runs today, it checks if it has been more than 1 day since
any daily cron jobs were supposed to fire. Right?
So, if the cron job for updatedb was set to fire today and didn't,
anacron realizes that it's still today and that it hasn't yet been 1
full day since that job was supposed to fire, so it ignores it until
tomorrow, at which point it will have been 1 day since the job was
supposed to fire and didn't. Right?
If so, that explains some of the lag I experience in the locate
database often not containing what I expect it to have. After all,
from that scenario, anacron doesn't run today's cron job. It runs
yesterday's cron job, and that's exactly as it should be, right?
>I've certainly never had to run locate's database update manually,
>it has always been updated automatically.
I guess that, for me, it's normal to run it often because I make a
lot of rapid changes to my file system throughout the day and tend to
need to search through them. I couldn't do what I do if I had to wait
until the next day for those to be added to the database.
>However it apparently doesn't check if a system is running on battery
>so maybe that's what you have noticed.
No idea, but in my case, this is a desktop computer that I turn off
every night and on every morning.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list