The Drupal cron task ensures that regular database maintenance has occurred. Often security related jobs are tied to cron. Ensuring cron runs on a regular basis (for instance in the last day or so) helps improve site stability, a building block for good security. Ultimately it's probably a good idea to make the timeframe for this check configurable, but to start 24 hours seems reasonable. This type of check is handy if you're running security reports regularly to spot problem conditions before they get out of hand.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Justin_KleinKeane’s picture

StatusFileSize
new2.23 KB

Attaching a patch that will check for cron running in the last 24 hours.

greggles’s picture

Status: Active » Needs review

Better status.

I didn't test or look at the code much.

One nitpick is that comments should end with a period.

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

As Drupal6 has been EOL https://www.drupal.org/about/drupal6-eol closing as outdated

greggles’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev
Status: Closed (outdated) » Needs work

This one also feels nice to keep in modern versions as cron is still important, I believe, for security.

smustgrave’s picture

Not sure what to check though. Each project runs cron at different intervals. Or if you use ultimate cron some cron jobs run at different times.

greggles’s picture

Assigned: Justin_KleinKeane » Unassigned

If the dblog module is enabled and if there are messages in the table about cron that seems like enough to me?

I guess a more robust solution is this module could have its own cron task that sets a variable to the last time it ran and then during review phase if that variable is too old it would alert that cron is not running?

smustgrave’s picture

what do we consider too old though? That could be different per site. 24hours?

smustgrave’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
greggles’s picture

Title: Check that cron has been run recently » Check that cron has been run recently - in the last 72 hours

For purposes of the module I think the really bad situation would be if cron hadn't run in a long time (days, weeks, etc.). Seems good to check it has run in the last ~72 hours?

If we use 24 and a site has cron running once a day then there's a risk if cron doesn't run for 1 day or is late that it would get flagged as a problem when that's not really a problem. It seems good to balance the security and not sending too many error messages.

smustgrave’s picture

Status: Needs work » Needs review
StatusFileSize
new2.81 KB

Try this.

greggles’s picture

The quotes (double vs single) are a little inconsistent on the user-facing strings here:

+        return $this->t("Unexpected result.");

Otherwise LGTM!

smustgrave’s picture

StatusFileSize
new2.81 KB

Updated.

greggles’s picture

Status: Needs review » Reviewed & tested by the community

LGTM. Thanks.

  • smustgrave committed 193a86c on 2.0.x
    Issue #1244238: Check that cron has been run recently - in the last 72...
smustgrave’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.