The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Abdullah Mohammed -
Number of replies: 6
Dear Friends,

I have this problem after I upgraded Moodle to version 4.2 knowing that the Cron Job is correct, but I see the two messages below

The first message: The admin/cli/cron.php script has not been run for 11 hours and should run every 1 min.

Second message: !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!! ( when i run Cron output)


my hosting provider is hostinger and php v is 8.1 and moodle v is 4.2

please see the photos

Attachment xx1.png
Attachment xx2.png
Average of ratings: -
In reply to Abdullah Mohammed

Re: The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Typically incompatible PHP versions bring this. Check https://moodledev.io/general/releases/4.2#server-requirements.
In reply to Visvanath Ratnaweera

Re: The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Abdullah Mohammed -
My Php Verstion is 8.1 and according to the Environment page every thing is ok 
Attachment screencapture-alsalim-org-admin-environment-php-2023-05-07-16_24_01.png
In reply to Abdullah Mohammed

Re: The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Ken Task -
Picture of Particularly helpful Moodlers
On linux servers there are 2 php executables.   The web based environment check shows the php for the web.   For the cron job, it requires the same php version of php-cli (php for the command line).

Do you have Terminal access via cPanel or other Panel?

If so, click it and at the first prompt at the CLI, issue the following command:
which php
That will show which php-cli your system finds path.
use the path you see ... might be /usr/local/bin/php to see what version which command found first:
/path/to/php -v
If it is the correct path to 8.1, you will see the version - 8.1.   If it is not the correct path, you will see a version of php lower than 8.1.

If using cPanel, one usually has a multiphp tool ... set the domain's php to 8.1 there.   Also check cPanel's setting for cron job.

If the above is too confusing and/or you don't have Terminal icon, contact your hosting provider, for how to setup your cron job to point to the php-cli version 8.1 of PHP.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Harald Maruschewski -
Hello, I have got the same problem. admin/cli/cron.php did not run after updating to Moodle 4.2. The provider confirmed that it is running each minute on the server side. 
So, what can I do? Each hint is welcome! I wanted to duplicate courses but it did not work.
In reply to Harald Maruschewski

Re: The admin/cli/cron.php script has not been run for & !!! خطأ - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I have seen others with this issue and it was stemming from the upgrade to php 8.0 - I suspect you just need to make sure where php is located now and maybe change the link to reflect the location.