Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77186

Add a keep-alive setting to admin/cli/cron.php

XMLWordPrintable

    • MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-77186-master
    • Hide
      1. Perform upgrade
        1. Confirm no errors
      2. Login as admin
      3. Navigate to Site admin > Server > Tasks > Task processing
        1. Confirm that the default value of the cron_keepalive setting is 3 minutes
      4. Enable cron via Web interface:
        1. Go to Site security settings
        2. Uncheck Cron execution via command line only (cronclionly)
      5. Navigate to http://yoursite/admin/cron.php
        1. Confirm that the cron output some content
      6. Jump to the bottom of the output
      7. Find the line which starts "Cron completed"
        1. Confirm that it did not include a "Continuing to check" message in it
      8. Open a Terminal
      9. Run the CLI cron runner:

        php admin/cli/cron.php
        

        1. Confirm that the cron output some content
      10. Jump to the bottom of the output
      11. Find the line which starts "Cron completed"
        1. Confirm that it did include a "Continuing to check" message in it, for example:

          Cron completed at 08:25:08 in 0.680058 seconds. Memory used: 42.0 MB. Continuing to check for tasks for 58 more seconds.
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          

      12. The task should keep repeating and the cron should keep checking for tasks for those 3 minutes.
        1. Confirm that it does so
        2. Confirm that when the timer runs out, the runner exits
      13. In the UI, find the cron_keepalive setting again
      14. Try to set it to -1 seconds and save changes
        1. Confirm that you got a "Too low" message
      15. Try to set it to 55 minutes and save changes
        1. Confirm that you got a "Too high" message
      16. Set it to five seconds and save changes
        1. Confirm that the setting was saved
      17. Run the CLI cron runner again
        1. Confirm that the runner only ran for five seconds and exited
      18. Run cron and specify a keep-alive value:

        php admin/cli/cron.php --keep-alive=10
        

        1. Confirm that the runner only ran for 10 seconds and exited
      19. Specify a no-keep-alive option:

        php admin/cli/cron.php --no-keep-alive
        

        1. Confirm that the cron ran once, and exited
      20. Specify an empty value:

        php admin/cli/cron.php --keep-alive=0
        

        1. Confirm that the cron ran once, and exited
      21. Specify a negative value:

        php admin/cli/cron.php --keep-alive=-4
        

        1. Confirm that the cron ran once, and exited
      22. Specify a high value:

        php admin/cli/cron.php --keep-alive=999
        

        1. Confirm that you were shown a warning message:

          Cron keepalive time is too long, reducing to 15 minutes.
          

        2. Confirm that the cron run had a 15 minute time (900 seconds),
          Note: You can hit Control+C to cancel early rather than waiting for the full 15 minutes.
      23. Run again and wait for the "Continuing to check..." message
      24. As soon as it comes up, press Ctrl+C
        1. Confirm that you were shown a graceful exit message

          == Exiting gracefully, please wait ... ==
          

        2. Confirm that it exists basically immediately
      25. Install the attached moodle-local_crontest-arn.php into local/crontest
      26. Run two copies of the cron runner wtih a keepalive of 3 minutes and space them apart slightly (i.e. 30 seconds between starting each)
      27. Run local/crontest/cli/add_adhoc.php
        1. Confirm that one of the cron runners picks up the first task
        2. Confirm that a few seconds later the second runner picks up the second task
      Show
      Perform upgrade Confirm no errors Login as admin Navigate to Site admin > Server > Tasks > Task processing Confirm that the default value of the cron_keepalive setting is 3 minutes Enable cron via Web interface: Go to Site security settings Uncheck Cron execution via command line only (cronclionly) Navigate to http://yoursite/admin/cron.php Confirm that the cron output some content Jump to the bottom of the output Find the line which starts " Cron completed " Confirm that it did not include a "Continuing to check" message in it Open a Terminal Run the CLI cron runner: php admin/cli/cron.php Confirm that the cron output some content Jump to the bottom of the output Find the line which starts " Cron completed " Confirm that it did include a "Continuing to check" message in it, for example: Cron completed at 08:25:08 in 0.680058 seconds. Memory used: 42.0 MB. Continuing to check for tasks for 58 more seconds. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The task should keep repeating and the cron should keep checking for tasks for those 3 minutes. Confirm that it does so Confirm that when the timer runs out, the runner exits In the UI, find the cron_keepalive setting again Try to set it to -1 seconds and save changes Confirm that you got a "Too low" message Try to set it to 55 minutes and save changes Confirm that you got a "Too high" message Set it to five seconds and save changes Confirm that the setting was saved Run the CLI cron runner again Confirm that the runner only ran for five seconds and exited Run cron and specify a keep-alive value: php admin/cli/cron.php --keep-alive=10 Confirm that the runner only ran for 10 seconds and exited Specify a no-keep-alive option: php admin/cli/cron.php --no-keep-alive Confirm that the cron ran once, and exited Specify an empty value: php admin/cli/cron.php --keep-alive=0 Confirm that the cron ran once, and exited Specify a negative value: php admin/cli/cron.php --keep-alive=-4 Confirm that the cron ran once, and exited Specify a high value: php admin/cli/cron.php --keep-alive=999 Confirm that you were shown a warning message : Cron keepalive time is too long, reducing to 15 minutes. Confirm that the cron run had a 15 minute time (900 seconds), Note: You can hit Control+C to cancel early rather than waiting for the full 15 minutes. Run again and wait for the "Continuing to check..." message As soon as it comes up, press Ctrl+C Confirm that you were shown a graceful exit message == Exiting gracefully, please wait ... == Confirm that it exists basically immediately Install the attached moodle-local_crontest-arn.php into local/crontest Run two copies of the cron runner wtih a keepalive of 3 minutes and space them apart slightly (i.e. 30 seconds between starting each) Run local/crontest/cli/add_adhoc.php Confirm that one of the cron runners picks up the first task Confirm that a few seconds later the second runner picks up the second task

      As dicussed with matt.porritt@moodle.com, it would be useful to have a keep-alive setting in cron so that the cron runner doesn't exit immediately if nothing is in the queue.

      This should be similar to the keep-alive setting available in admin/cli/adhoc_task.php, but perhaps configured from the UI with a default of 59 seconds. We may also want to introduce the ability to add a poll frequency configuration setting within that.

      This will allow sites to run adhoc tasks closer to their intended start times.

        1. 2 cron.gif
          2 cron.gif
          1015 kB
        2. cron 0 sec.gif
          cron 0 sec.gif
          1.34 MB
        3. cron-10 sec.gif
          cron-10 sec.gif
          2.03 MB
        4. cron- large time and close.gif
          cron- large time and close.gif
          6.58 MB
        5. cron - negative.gif
          cron - negative.gif
          897 kB
        6. cron-no.gif
          cron-no.gif
          1.08 MB
        7. MDL-77186.png
          MDL-77186.png
          1013 kB
        8. moodle-local_crontest.zip
          4 kB
        9. moodle-local_crontest-arn.zip
          5 kB

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Laurent DAVID Laurent DAVID
            Jake Dallimore Jake Dallimore
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 44 minutes
                6h 44m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.