Moodle
  1. Moodle
  2. MDL-8269

cron runs at midnight regarless of setting

    Details

    • Affected Branches:
      MOODLE_17_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      29263

      Description

      Affects Version/s may go back prior to 1.7.

      I was writing my own cron code and was using Moodle's for a reference. I wanted one task to be executed at a specific time like Moodle's statistics. I found that Moodle's admin/cron.php uses the following line to get the time:

      $timetocheck = strtotime("$CFG->statsruntimestarthour:$CFG->statsruntimestartminute today");

      This always seems return midnight. I switch it to the following and I have had more success:

      $timetocheck = strtotime("today $CFG->statsruntimestarthour:$CFG->statsruntimestartminute");

      A diff off of HEAD is attached.

      1. cron.diff
        0.7 kB
        Mark Nielsen

        Activity

        Hide
        Mark Nielsen added a comment -

        Forgot to add, I have not actually tested the diff I was just looking at the returned time from the strtotime() function in my development code.

        Show
        Mark Nielsen added a comment - Forgot to add, I have not actually tested the diff I was just looking at the returned time from the strtotime() function in my development code.
        Hide
        Mark Schumann added a comment -

        I'm getting a similar issue, although my statistics processing seems to be running at midday.

        Show
        Mark Schumann added a comment - I'm getting a similar issue, although my statistics processing seems to be running at midday.
        Hide
        Michael Penney added a comment -

        Was this fixed?

        Show
        Michael Penney added a comment - Was this fixed?
        Hide
        Dan Poltawski added a comment -

        Thanks for the report and fix. I've fixed this in CVS (finally!)

        Show
        Dan Poltawski added a comment - Thanks for the report and fix. I've fixed this in CVS (finally!)
        Hide
        Anthony Borrow added a comment -

        Dan - I'll just comment rather than re-opening about checking about backporting to 1.7 and 1.6. Peace - Anthony

        Show
        Anthony Borrow added a comment - Dan - I'll just comment rather than re-opening about checking about backporting to 1.7 and 1.6. Peace - Anthony
        Hide
        Dan Poltawski added a comment -

        Backported to 1.6/1.7 now

        Show
        Dan Poltawski added a comment - Backported to 1.6/1.7 now

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: