cron.php is not running scheduled tasks

cron.php is not running scheduled tasks

by Szymon Katra -
Number of replies: 12

Good morning.

I'm using Moodle 3.4+ (Build: 20171208).

I set up crontab on my server to run admin/cli/cron.php every minute and save logs to file. Cron is running cron.php correctly, but problem is that script is not running any of scheduled tasks. Output from cron.php looks like this:

"Server Time: Tue, 26 Dec 2017 19:37:51 +0100"

and that's all. Running script directly from command line via SSH gives exactly the same result. 

When I naviage into "Administration > Site administration > Server > Scheduled Tasks" I see that for all tasks last execution time is "never", until I explictly run one of them using "Run now" link above.

Regards.

Average of ratings: -
In reply to Szymon Katra

Re: cron.php is not running scheduled tasks

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Just to check... what is the command line you are using?

In reply to Howard Miller

Odp: Re: cron.php is not running scheduled tasks

by Szymon Katra -

I don't understand. I'm just logging in to my server via SSH and run for example "php admin/cli/cron.php".

In reply to Szymon Katra

Re: Odp: Re: cron.php is not running scheduled tasks

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That was what I was asking. It is, of course, the correct command.

Switch on Debugging and try again...

In reply to Howard Miller

Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Szymon Katra -
I switched to DEVELOPER mode and got this: https://pastebin.com/Vy8L2fVV
In reply to Szymon Katra

Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Ken Task -
Picture of Particularly helpful Moodlers

In your first posting ...

'and save logs to file.' ... which suggest one is not running

php admin/cli/cron.php all by itself (which is what you tested).

What does the command look like in cron tab with the 'and save logs to file' look like?

**Something** like this:

/usr/bin/php /srv/www/moodle/admin/cli/cron.php >/tmp/moodle_cron.log 2>&1

IF that's true, then one could watch the moodle_cron.log file in realtime ...

tail -f /tmp/moodle_cron.log

You substitute things above to suit your setup.

'spirit of sharing', Ken



Average of ratings: Useful (1)
In reply to Szymon Katra

Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What do you mean, "you got this..."?

What exactly did you do and what happened (when you ran the cron command on the command line)?

In reply to Howard Miller

Odp: Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Szymon Katra -

I've run "php admin/cli/cron.php" command on my server and it has printed on console what I sent in previous post (https://pastebin.com/Vy8L2fVV)

In reply to Szymon Katra

Re: Odp: Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle did not produce that output... so something else is going on. Have you asked your host's support about this? I suspect something unusual with your local cron setup. 

In reply to Szymon Katra

Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Ken Task -
Picture of Particularly helpful Moodlers

Please see:

A lock was created but not released discussion:

https://moodle.org/mod/forum/discuss.php?d=315746

Site is running varnish with nginx.

'spirit of sharing', Ken


In reply to Ken Task

Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

...but (unless I'm missing something) he didn't say that he got that message. 

In reply to Ken Task

Odp: Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Szymon Katra -

Thanks, but what can I do for that? I switched to database locks in my config.php and now I get this:

Fatal error: Call to a member function real_escape_string() on null in /usr/home/zseinstalacje.usermd.net/public_html/lib/dml/mysqli_native_moodle_database.php on line 1083

In reply to Szymon Katra

Odp: Re: Odp: Re: Odp: Re: cron.php is not running scheduled tasks

by Szymon Katra -

Ok, I solved problem.  "php" from command line was using old php 5.6 instead of 7.1


Thanks for help.

Average of ratings: Useful (1)