Search code examples
phpcronmoodleshared-hostingintl

Scheduled tasks not running on moodle


When the cron job for moodle runs I get this output:

Execute scheduled task: Clean up ad hoc task metadata (core\task\task_lock_cleanup_task)
!!! Exception - Class 'IntlTimeZone' not found !!!

Fatal error: Uncaught Error: Call to a member function real_escape_string() on null in /home/cbisacok/public_html/lib/dml/mysqli_native_moodle_database.php:1145
Stack trace:
#0 /home/cbisacok/public_html/lib/dml/mysqli_native_moodle_database.php(1274): mysqli_native_moodle_database->emulate_bound_params('SELECT RELEASE_...', Array)
#1 /home/cbisacok/public_html/lib/dml/moodle_database.php(1679): mysqli_native_moodle_database->get_records_sql('SELECT RELEASE_...', Array, 0, 0)
#2 /home/cbisacok/public_html/lib/classes/lock/mysql_lock_factory.php(161): moodle_database->get_record_sql('SELECT RELEASE_...', Array)
#3 /home/cbisacok/public_html/lib/classes/lock/lock.php(120): core\lock\mysql_lock_factory->release_lock(Object(core\lock\lock))
#4 /home/cbisacok/public_html/lib/classes/lock/lock.php(134): core\lock\lock->release()
#5 [internal function]: core\lock\lock->__destruct()
#6 {main}
  thrown in /home/cbisacok/public_html/lib/dml/mysqli_native_moodle_database.php on line 1145

I'm running moodle on shared hosting on namecheap. i'm on moodle version 4.1.4 and i'm using PHP Version 8.0.30 I have intl enabled in the php settings it looks like this: enter image description here and here is some addtional system information: enter image description here Please let me know if there is anymore information I can add that would be helpful. This problem causes non of the sheduled tasks in moodle to run

I'm kind of at a lost on how to move forward debugging this problem...


Solution

  • Cron uses the cli version of PHP, phpinfo() uses the server/Apache version of PHP

    Check if the cli version is the same (note Moodle 4.1.4 supports up to PHP 8.1 but not 8.2)

    php -v
    

    And has intl enabled

    php -m
    

    You can also run a scheduled task from the command line to test it, which might give you more info

    https://docs.moodle.org/403/en/Administration_via_command_line#Scheduled_tasks

    eg:

    php admin/cli/scheduled_task.php --showdebugging --execute='\core\task\task_lock_cleanup_task'
    

    There is also a command line tool to check the status

    php admin/cli/checks.php