As I was working on a module I realized that Drupal doesn't keep track of the last cron run, which is strange, since it adds a watchdog() after every run but nothing keeps track of the time of the last run. So this patch fixes that and as a result, cleans up a few core modules to make use of this new variable.

Additionally, since we can keep track of the last cron run, it makes sense to test to see if cron is configured properly. Neil suggested this as a result of my proposed patch so I expanded it's capabilities to do just that. On the settings page there is new 'cron jobs' section which notifies the user of the status of cron: it's running, it hasn't run within the past 1.5 hours (Neil suggested this time check, I agree, Drupal installs probably benefit most from 1.5 hour checks), or it hasn't run at all. This really makes setting up cron a bit easier and also makes it easier to pinpoint any errors if cron for some reason or other stops running.

CommentFileSizeAuthor
#6 cron_3.patch4.91 KBm3avrck
#2 cron_2.patch4.62 KBm3avrck
cron_1.patch4.6 KBm3avrck

Comments

Steven’s picture

It is preferable to put URLs outside of translatable strings, like this:
t('Linking to <a href="%url">some page</a>.', array('%url' => 'http://...'));

m3avrck’s picture

StatusFileSize
new4.62 KB

Nice catch Steven, new patch attached.

drumm’s picture

Lets put an update in updates.inc to clear out those old vaiables (and maybe copy the value into the new variable).

dries’s picture

Why does cron have to run every 1.5 hours? Isn't that a reasonably short interval? Does that align with cron-curl.sh and cron-lynx.sh?

dries’s picture

I think it is sufficient to know that cron runs, and that it last ran x hours/minutes ago. It doesn't really matter whether it ran within the 1.5 hour. I'd modify the patch. Just say, 'cron ran x ago' using format_interval().

m3avrck’s picture

StatusFileSize
new4.91 KB

Drumm, nice catch, patch updated to clear those variables and set the new one.

Dries, good idea as well, that seems to make the most sense. We came up with the 1.5 hours last night (late and tired!) but after thinking about that today, it seems to make the most sense. If it says cron last run 4 weeks, 2 days ago, then the user/admin will obviously know if that number is good or bad.

Patch has been updated, should be good to go now.

drumm’s picture

Code looks okay. +1

m3avrck’s picture

Status: Needs review » Reviewed & tested by the community

Just talked with Drumm on IRC, says we should set this to commit, nothing is in the way. And I'll be out of town for a week so I can't reroll this later if other updates make it in before this.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)