On Wednesday 05 March 2003 3:59 am, Mitch Thompson wrote:
On Thursday 27 February 2003 10:43, Prabu Subroto wrote: [...] The actual running of the cron job that updates the locate database is done by the file /etc/cron.daily/updatedb. ... If the time that it is running is inappropriate for your system, maybe you should change cron to run it at a time that is more system-load appropriate.
The line to change is in file /etc/crontab:
14 0 * * * root rm -f /var/spool/cron/lastrun/cron.daily
The "14" is the minutes, the "0" is the hour(using a 24 hour clock),
So, on my system, updatedb runs daily, along with all other scripts in /etc/cron.daily, at 14 minutes past midnight.
Close, but not quite -- the ACTUAL actual routine that runs is (usually) the first item in the file -- the one that reads -*/15 * * * * root test -x /usr/lib/cron/run-crons && [...] [I've chopped it a little shorter for the e-mail, but there is enough here to see what is going on] Basically, "every 15 minutes" the routine "run-crons" gets fired up. run-crons does "some checking" and eventually fires off anything found in a /etc/cron.* directory (.daily, .hourly, .weekly, and .monthly) -IF- the corresponding file in /var/cron/lastrun doesn't exist. Changing the other lines to change the time at which the "lastrun" file gets purged works well if you change the time to EARLIER than it is now. Otherwise, it will run twice -- once at the original time, and again at the time you've changed [but this happens only once] The reason for this is that INTERNAL to the run-crons script is a little bit of logic that purges the "lastrun" file if the timestamp is older than [one hour, one day, one week, or OLDER than the current day of the month in days (think about it...)] For instance, if the "daily" lastrun file gets purged at 2:00am currently, and you change the "rm .../lastrun/daily" crontab entry to purge the file at 1:00am, then it works OK -- at 1:00am "the first time", the file is only 23 hours hold, but since the "external" crontab item is absolute, the file gets purged and (up to) 15 minutes later the "daily" routine actually runs. If, however, you change this to 4:00am, then what happens is that at 2:00am "the next day", the run-crons script sees that the age is now "1 day" [24 hours] and purges the file, hence the script continues to run at 2:00am. 2 hours later, at 4:00am, the "change" to the other crontab entry occurs, the "daily" file get purged again [now only 2 hours old] and the "daily" routine repeats for a second time. After this, however, the NEXT day at 2:00 am the file is only 22 hours old, so "run-crons" doesn't purge the file. Now, where this gets "annoying" is the case where you go on a camping trip over the weekend and actually SHUT DOWN the computer while you're away. come monday morning, when you "want to catch up" on e-mail or newsgroups, you fire up the computer, get past the boot process, login, fire up your browser / e-mail / newsgroup client, get started downloading things, and your computer goes into "molasses mode" -- yup, the time is now 8:15 am [for example] and run-crons has detected that the "lastrun" of "cron.daily" is indeed more than 24 hours ago, so it MUST be time to "do whatever" -- Yet another Blog: http://osnut.homelinux.net