Moodle says:
The admin/cli/cron.php script has not been run for 3 days 3 hours and should run every 1 min.
cron email says:
!!! Exception - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!
(To make sure it wasn't a security problem, I checked cron.php and it was 664.)
I tried submitting a ticket in Tracker (jira), but it says I failed to demonstrate that I searched existing tickets. But I did! I don't know what kind of proof they want.
Any insights? Thanks!
-- Russ Schwartz
The Moodle Server Check says:
version 8.0.0 is required and you are running 8.0.28
I checked my service provider and they, too, said I was running php 8.0
I'll check the documentation further per your recommendation ...
-- Russ
-- Russ
When I issued those commands that Ken Task suggested, I saw:
PHP 7.4.30 (cli) (built: Sep 13 2022 05:22:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
BUT: The Moodle Server Check says:
version 8.0.0 is required and you are running 8.0.28
So now I have a ticket in back at my Web Host saying, "Okay, which version am I really running?" (In an earlier message, where I asked them if I was running 64-bit 8.0, they said yes. Hmmm....)
AND: My Web Host says:
This domain is using PHP 8.0 FastCGI
Re: Plot "sickens..." LOL!
Interesting, my provider told me that the PHP that Moodle runs and the PHP the ssh sees (which I determined using the commands you gave me) are two different things. Who knew?
I define my cron job on my provider's server with an unnamed tools. I type in a command, click some pull-downs about when to run it, press a button, and that's it.
Here's the command:
/usr/bin/php /home/licc_admin/liberiainternationalcc.org/moodle/admin/cli/cron.php
I got that out of the 4.1 release notes when I installed Moodle. Now I need to check the 4.2 release notes to see if anything changed.
Also, I want to do some/all of the stuff you mentioned in your 2 most recent messages. What should keep me busy for a while!
Thanks again for the help. It's shown me what questions to ask my provider, how to interpret their answers that are sometimes beyond my competence, and to check things myself before I ask questions so I can pretend to know what's going on. ;)
-- Russ
[daniel-carroll]$ ls -l /usr/bin/php
lrwxrwxrwx 1 root root 21 Feb 2 2020 /usr/bin/php -> /etc/alternatives/php
[daniel-carroll]$ cd /opt/
[daniel-carroll]$ find ./ -name php
find: './plow': Permission denied
Then I had a brainstorm: Why not try to see what cron sees?
So first I created a cron job that issued the command: which php
The output was: /usr/bin/php
So I modified the job to give the command: /usr/bin/php -v
and the output was:
PHP 7.4.30 (cli) (built: Sep 13 2022 05:22:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
That would explain the error.
But why does Moodle tell me that it's running 8.0.28 ?
And why does my provider insist that my Moodle site is running 8.0 ?
No matter. My provider sent me an article entitled "Change the PHP version the shell uses"
So I will try that next.
As Paul Harvey used to say, "Stand by for news!"
They told me to add this line to my .bash_profile file:
export PATH=/usr/local/php82/bin:$PATH
and then execute this command:
. ~/.bash_profile
And, at least when I do a "php -v" from within ssh, 8.2 is what's now running.
So now the big wait is to see what happens when the cron job runs and finishes.
(I should mention that the server / php info report still thinks Moodle is running 8.0.28)
If this doesn't work, then I'll ask my provider to just out-and-out change me so I'm running 8.1 or better anywhere -- in ssh, in cron, whatever.
And when I connect to the server using ssh and do a php -v I am running 8.0.23 as noted.
But Moodle still thinks it is running a different PHP version. (It's 8.1.17 since I upgraded the web site.)
And the cron is still failing.
I'm getting confused. It looks like there is one PHP that runs under ssh, another version that runs under cron, and a third version that runs when I just go to Moodle in my browser.
I have a ticket in to my provider saying, "Please make everything run under one version."
I'm definitely "in over my head" here....
I have no idea what user the cron job runs under. The messages I get from cron have subject lines like this:
Cron <admin_acct_name@server_name> /usr/local/bin/setlock -n /tmp/cronlock.2901942.250631 sh -c '/usr/bin/php /home/admin_acct_name/web_site_name/moodle/admin/cli/cron.php'
where admin_acct_name and web_site_name are disguises in this message for the real names.
I assume the cron job is running under admin_acct_name, but I don't know that.
Now we'll see what my service provider says/does....
Several articles on cron jobs
A few on Moodle
https://help.dreamhost.com/hc/en-us/search?utf8=%E2%9C%93&query=moodle&commit=Search
And Moodle has official docs on Cron
Re: Use of knowledge base. I agree completely. When I worked at Digital Equipment Corporation back in the 80s, we had the EasyNet, which was very much like the Internet except that the Application Layer was different. Conversations like you and I are now having were in an app called VAXNotes. Each product also had its own VAXNotes app, which was its knowledge base. When we would call the help desk in Colorado Springs, their Question #1 was always, "Did you read the Notes files?
I have to thank you for your patience with me. Elsewhere, I posted that I am on assignment in a country that is much hotter and more humid than my own. I have made a variety of poor choices (such as installing a non-LTS Moodle, and doing so the day it was announced) do to my brain not working right. Mea Culpa! I must plead temporary insanity! ;)
I shall (1) read the recommended articles, (2) see if I can go back to PHP 8.0 through my site manager, and (3) per DreamHost, modify .bash_profile to use the "alias" command instead of the other one.
-- Russ
Please note that that the problem I have been experiencing here is "normal and expected" for almost any application.
A developer can build all kinds of rules into application software and triggers and constraints into databases to protect users from themselves. But system management is always risky territory. Some tasks, not done right, can be disruptive or destructive. (Moodle gives advice on this when you set certain system parameters.)
For this reason, I almost always log in using a Teacher role. I only log in as Administrator when I need a higher-than-normal privilege to do something.
I beg you not to conclude from this conversation that Moodle is "buggy" or otherwise lacking in quality. The problems I am having are my own fault, not those of the Moodle developers or quality unit. My opinion of Moodle has not diminished in any way.
I am still a #1 Moodle Fan! <3 <3 <3
Moodle for hotter and more humid countries ;-) [OT]
Re: Moodle for hotter and more humid countries ;-) [OT]
-- Russ
Here is where I am now:
I have put the web site back to PHP 8.0 FastCGI as required by Moodle 4.2
alias php='/usr/local/php80/bin/php'
The cron job is still giving me this error:
!!! Exception - syntax error, unexpected ')', expecting variable (T_VARIABLE) !!!
I enabled the deprecated web-based cron command with password required (to thwart the "black hats" as Ken mentioned). I ran it and it completed successfully.
It seems like I am set up about 98% right. There must be some small thing that is escaping DreamHost or me. Perhaps it has something to do with what Visavanath about "running as the owner of the web process". I doubt I have server privileges to run jobs under any other user id than my own, but I'll check around ...
-- Russ
You wrote:
> put the web site back to PHP 8.0 FastCGI as required by Moodle 4.2
PHP 8.0 is the key. It could be FastCGI or PHP-FPM. May be other models too. Or do you have a quote which says otherwise?
> I doubt I have server privileges to run jobs under any other user id than my own,
If you are the true 'root', you can:
# crontab -u TARGET-USER -e
I shall pass this on to DreamHost and see if somebody with privileges will use crontab to force the "-u"
-- Russ
Regarding the error message you are seeing, "!!! Exception - syntax
error, unexpected ')', expecting variable (T_VARIABLE) !!!", this
typically indicates that there is a syntax error in the code that is
being executed by the cron job. The error message specifically suggests
that the code is encountering an unexpected closing parenthesis ")" where
a variable should be expected.
Has this issue devolved to finger-pointing? I'm surprised. It's not like DreamHost to do that ...
Question: Why does a program throw a syntax error during compilation?
DH: Because the program code has a coding error.
What DH overlooked: The programming language has changed! The new compiler doesn't like the old code!
PHP 8.0 is the key. It could be FastCGI or PHP-FPM. May be other models too. Or do you have a quote which says otherwise?
I have 2 choices: (a) FastCGI 8.0 or (b) CGI 8.0.
Currently, my site is set up for FastCGI 8.0. As soon as i get through the current dialogue with DreamHost, I shall switch to "regular" CGI 8.0 and see what happens.
-- Russ
I mis-spoke. Originally I had PHP 8.0 FastCGI. I changed to PHP 8.1 FastCGI. When I learned that Moodle 4.2 wants 8.0, I changed back to PHP 8.0 FastCGI because that's what I had before. By "required" I only meant 8.0, but my grammar implied 8.0 FastCGI. Sorry to mislead....
Before I try CGI 8.0, I will leave it at FastCGI 8.0. DreamHost told me I could work around my crontab privilege problems by showing me a KB article on how to create my own crontab file that takes precedence over the server's file.
I'm going to try that and see what happens....
Ken: >> > Does your provider have a panel (cPanel by name) for customers to use? If they do, use that to set up the cron job. >>> I'll answer that for you: no DreamHost does not offer cPanel, but does offer one of their own: Yes, I was using that one until this morning. Then I deleted it. >>> And since their KB is public, what's the url to the KB article they shared with you? >>> This one? DreamHost sent me this same article, so I created a new cron job this way. It does not appear to be running ... at all. I am not getting any emails back from the job. Now I have a ticket in on that one. >>> Here's another DreamHost specific KB article that you need to read: That one is informative, although I'm not sure what action I should take as a result. I'm about ready to punt. If they can't tell me why my newest cron job -- which they told me to create -- and which I created following their instructions -- does not run, then I'm done. I think Visvanath's earlier "Poor DreamHost" comment pretty much sums up the situation. I have enabled the web execution of cron.php (with password!) and I will just run it 2-3 times a day until the semester is over. Then I'll back up everything, delete all the files, and reinstall Moodle 4.1. Thanks for the help. I think we got very close. -- Russ |
In your very first post you said, "having cron problems after upgrading to Moodle 4.2 from Moodle 4.1". How was cron running then?
Ubuntu 18.04 LTS 'Bionic Beaver', one of the most popular Ubuntu releases, will reach the end of the standard, five-year maintenance window for Long-Term Support (LTS) releases on 31 May 2023.
Ran 0 adhoc tasks found at Sun, 30 Apr 2023 05:51:27 +0000
Status | Check
----------+--------------------------------------------------------------------
WARNING | Cron running (tool_task_cronrunning)
| The admin/cron.php script has not been run for 3 mins 14
| secs and should run every 1 min.
ERROR | Tasks max fail delay (tool_task_maxfaildelay)
| 4 task(s) failing
Site administration > Server > Tasks > Task processing > Keep alive time
The default is set to 3minutes and it’s the main cause of the cron log constantly (each second) filling of messages after the tasks run once.
I did’nt noticed this change until your message, but now I modified it to 0 and the cron behaviour it’s back to the “old way”.
I just changed the keep alive time to zero (0) minutes.
-- Russ
First thing is to identify whether the machine gives true super user access or some jail behind a Cpanel - in the best case a private Cpanel, the worst case is of course the hoster's Cpanel, which means that it is a shared host. At the rate the OP could jump from one to the other, I suspect a Cpanel, which'll leave me out.
Ubuntu 18.04: Yes, it is a well-tested, well-maintained OS, a LTS. EOL will not kill the system immediately. One can plan the exit route even medium term, means a 3-6 months.
Again, if it is a true VPS even a dist-upgrade is feasible. Ubuntu allows single-step dist-upgrades from LTS to LTS. But one doesn't have to tread such scary paths. Get a site backup, ask the hosting service for a new VPS, restore the site backup there. Either way, site backup part is a must - unless the OP is still at "proof-of-concept" stage. That is why I suggested a free MoodleCloud instance and avoid Unix/Linux gymnastics.
total used free shared buff/cache available
Mem: 31G 12G 2.0G 3.0G 16G 14G
Swap: 4.0G 825M 3.2G
I have probably used a poor word choice again. It appears in my quick browsing that some providers have an app called cpanel or something like that that manages cron jobs. Some replies have questioned how I could delete the cpanel and still have cron jobs.
To be clear: I did not delete any application. When I log on to DreamHost, I am at an web site whose home page is called the DreamHost Web Panel. It has menu options for buying new domain names, setting up web hosting, and more. One of those options is called "Cron jobs." When you pick that option, you can enter many of the parameters for a cron job that you are cryptical if you use crontab.
For Moodle 4.1 and part of 4.2, I was running the Moodle cron job from this application. Someone suggested that because it was unclear which php version was running under that application, I should use crontab instead and explicitly tell crontrab to use (me) as the user. Then I could control which php version is used.
So, I deleted the cron job that was in that app, and I recreated it in crontab. The KB article said I could have my own crontab file, which takes precedence over the system crontab file. So I created one.
So no capabilities have been deleted. I can still set up a cron job in DreamHost's Cron job application, or I can set one up in crontab. BUT: where the metadata for the job is stored is different for these 2 apps, and I think (but can't be certain) that much of the running environment is different, too.
-- Russ
https://docs.moodle.org/402/en/Cron
IMPORTANT: Do not skip setting up the cron process on your server for your Moodle. Your site will not work properly without it.
It is recommended that the cron is run every minute
More detail
https://docs.moodle.org/402/en/Cron_with_Unix_or_Linux
Question about 'meta-data' ... vr. 4 does have a report for cron.
And, if one follows the direction for setup of cron, that should have resulted
in getting an email message about cron once every minute. Don't think you'd want that. Unless your cPanel setup has a way to quiet that and log.
At one point in time, your system ran the cron job and logged the output.
Somewhere in /home/licc_admin/logs/yourdomain.org/
What I have done for you in admin/cli/ of moodle code is a bash shell script
called runcorn
source runcron
and now that you've fixed that looping issue (thanks again Sergio), it runs just fine:
clip of tail end:
Execute scheduled task: Background processing for scheduled allocation (workshopallocation_scheduled\task\cron_task)
... started 19:36:02. Current memory use 35.3 MB.
... no workshops awaiting scheduled allocation. ... used 1 dbqueries
... used 0.0012938976287842 seconds
Scheduled task complete: Background processing for scheduled allocation (workshopallocation_scheduled\task\cron_task)
Ran 0 adhoc tasks found at Sun, 30 Apr 2023 19:36:02 +0000
Cron run completed correctly
Cron completed at 19:36:02 in 1.329411 seconds. Memory used: 35.2 MB.
Your notifications screen in moodle should not be complaining now if you have set the cron job in your cPanel properly.
Indeed, if we were using trouble tickets, I would say that you could close it.
Thank you Ken, Visvanath, and Sergio. A small college in the world's fifth poorest nation is struggling to improve the quality of its education and to bring its technology into the second decade of the 21st Century. Your help was gratefuly appeciated!
-- Russ Schwartz
Re: cron failing after 4.1 to 4.2 upgrade [Solved]
Re: cron failing after 4.1 to 4.2 upgrade [Solved]
Your summary statement was so insightful that I gasped! You went right to the root cause of the problem.
Years ago, I was an IT guy, but now I am a teacher with few resources. Our school does not have an IT department. If Moodle works, it's because I make it work. However, as the old saying goes, "A fool with a tool is still a fool." And I am a fool with respect to Linux system administration. My curriculum and instruction work, as well as my teaching and (organizational) administrative duties consume my time and attention. When forced to do systems work, I do not do it well, and I make careless and (in this case) impulsive mistakes.
For this reason, I will very seriously consider Moodle Cloud when we scale up beyond my pilot course. I want something that "just works" and I don't have to think about it. If anything goes wrong, a phone call or email will trigger someone who knows what they are doing to fix it.
As for the MoodleBox concept, it does exist conceptually. The RACHEL server by worldpossible.org is a self-contained LMS as you mention. It has its own LMS, but we could easily fork a Moodle-based implementation. Unfortunately, the server is not cheap at $500 USD. But it's a start.
All the best,
-- Russ Schwartz
Re: cron failing after 4.1 to 4.2 upgrade [Solved]
The summary was easy. See how long I have been repeating the statement.
Visvanath asked me to consider using Moodle Cloud. Right now, I have just 2 courses and 2 "sandbox" courses that I am using for proof-of-concept. When the semester ends in June, I will wipe Moodle off the site and start over with a fresh LTS version. Later, if I decide that online learning is feasible at the school in the short-term, then I will seriously consider Moodle Cloud. I am 100% in favor of delegating system administration to somebody else. I retired from IT in 2011, and now I am a Curriculum and Instruction developer. In days gone by, I managed PDP-11s and VAXen, but my knowledge of Linux is pitifully small. Ken was commenting that I don't have sudo access on the server. Thank goodness! If I did, I'd probably mess things up even more: ;)
-- Russ