Cron failed to open stream

Cron failed to open stream

by Alistair Covlille -
Number of replies: 10

I'm coming at this from a windows background, so I am learning Linux (Ubuntu) and Moodle at the same time.

I am stuck trying to get the cron script to run.

I follow the guide, so Moodel is installed in /opt/moodle

The following command:

/usr/bin/php /opt/moodle/admin/cli/cron.php

gives the errors:

PHP Warning:  require(/opt/moodle/admin/cli/../../config.php): failed to open stream: No such file or directory in /opt/moodle/admin/cli/cron.php on line 33

PHP Fatal error:  require(): Failed opening required '/opt/moodle/admin/cli/../../config.php' (include_path='.:/usr/share/php') in /opt/moodle/admin/cli/cron.php on line 33

the problem line in cron.php is:

require(__DIR__.'/../../config.php');

What do I need to change this to?




Average of ratings: -
In reply to Alistair Covlille

Re: Cron failed to open stream

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
/opt is an odd place for a Debian-based system. (Ubuntu Linux is a Debian GNU/Linux derivative.) Typically the RedHat line follows that. Debian line has /var/www/html. But it is not a problem.

Try:
$ cd /opt/moodle
$ sudo -u www-data /usr/bin/php admin/cli/cron.php
[sudo] password for [..]: 

If it still breaks, paste the output of the following command here:

$ ls -l /opt/moodle/config.php

In reply to Visvanath Ratnaweera

Re: Cron failed to open stream

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I wonder if some package installer was involved...
In reply to Alistair Covlille

Re: Cron failed to open stream

by James Steerpike -
Picture of Particularly helpful Moodlers
One difference between Win and Linux is that, while under Win you can put a program nearly anywhere, Linux has definite places where a program should be. /opt as “reserved for the installation of add-on application software packages.” under the Filesystem Hierarchy Standard. Webserver applications normally run in a directory under/var/www/html I think you may have used git to get Moodle code but missed this step
sudo cp -R /opt/moodle /var/www/html/

Did you get Moodle to run in a browser? What is the documentroot in
cat /etc/apache2/sites-available/000-default.conf

Does it matter? One advantage of a rigid file system is you know where a file will be in a Linux system you are seeing for the first time. I think if I have strayed from the standard, I would try to get back to the /var/www/html/mood;e structure.
In reply to James Steerpike

Re: Cron failed to open stream

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi James

You said:
> under Win you can put a program nearly anywhere,

Are you sure? Try installing any medium sized Java application.
wink

> Linux has definite places where a program should be

No, they are not reserved in the OS. It is the opposite, you can have a file foobar (no file extension) which is text, a script, an image, a device, ... These places are advise so that people can conveniently compare one anothers work. Pl. don't misunderstand. These places creep in to configuration files. Changing them later means you need to back step and change them. So "free" until committed.
In reply to Visvanath Ratnaweera

Re: Cron failed to open stream

by James Steerpike -
Picture of Particularly helpful Moodlers
Serving web pages out of /opt is not usual. That suggests the installation guide followed was unusual or not followed correctly. My suggestion for someone learning Linux is to toast the install and start again.

My comment on placing files
Consider installing Openoffice under Windows and Linux. Under Win  you download and run an executable file which asks you where to install your new program. Linux uses a package manager such as apt and doesn't ask where to install.
Windows has to ask because there is no standard  place to install a program such as OpenOffice.  Linux has a file hierarchy based at / and has a place ready for every program so the concept of the right place is much stronger in Linux.
In reply to James Steerpike

Re: Cron failed to open stream

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> Serving web pages out of /opt is not usual. That suggests the installation guide followed was unusual or not followed correctly.

OR some sort of packaging we don't know. See the sub-thread https://moodle.org/mod/forum/discuss.php?d=431756#p1737445.

BTW, /opt is quite common in the BSD* Unix flavours.

> Consider installing Openoffice under Windows and Linux. Under Win you download and run an executable file which asks you where to install your new program. Linux uses a package manager such as apt and doesn't ask where to install.

Apparently the Windows version comes with all its libraries. Linux people (try to) avoid bloat, i.e. the software share libraries, which need coordination. That said these single "blob" monolith binaries are becoming fashion in Linux, specially with closed source software.

All that though is not relevant here, we are talking of the server side. Only Windows has the client and server messed up.
In reply to Visvanath Ratnaweera

Re: Cron failed to open stream

by Alistair Covlille -

The guide I followed was the one on the main Moodle site:

https://docs.moodle.org/311/en/Step-by-step_Installation_Guide_for_Ubuntu

which recommends installing to /opt


In reply to Alistair Covlille

Re: Cron failed to open stream

by James Steerpike -
Picture of Particularly helpful Moodlers
Https://docs.moodle.org/311/en/Step-by-step_Installation_Guide_for_Ubuntu
Git to /opt/moodle
Then
sudo cp -R /opt/moodle /var/www/html/
In reply to James Steerpike

Re: Cron failed to open stream

by James Steerpike -
Picture of Particularly helpful Moodlers
Translate that into English.
You use the git program to obtain the Moodle code into the staging area /opt
Then you copy all the Moodle code with subdirectories to /var/www/html. Which is where the Apache webserver expects to find and deliver the document root.
Maybe you can hack it to make it work under /opt but you have missed a step in the instructions.