Cron_enabled config goes back to uncheck

Cron_enabled config goes back to uncheck

by Hugo Ribeiro -
Number of replies: 7
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi all,
I was given a fresh Moodle 4.2 installation on Ubuntu 20.04 AWS Lightsail (I believe) and we are having issues setting up cron.
Oddly, the setting "cron_enabled" was off (the default option is on naturally) and each  I change it, it goes back to off and so cron.php isn't running by cli.

Any idea on what might be causing this strange behaviour?
Average of ratings: -
In reply to Hugo Ribeiro

Re: Cron_enabled config goes back to uncheck

by Ken Task -
Picture of Particularly helpful Moodlers
4.2 has issues with cron ...
When you actually run cron from command line, what does that look like?  Does it actually finish, or does it go into a loop after adhoc task - appearing to be in a never ending loop as it goes back to adhoc task briefly.

Saga here:

@Sergio ... you reading this ... can't find your posting on how to fix this now! sad

'SoS', Ken


In reply to Ken Task

Ri: Re: Cron_enabled config goes back to uncheck

by Sergio Rabellino -
Picture of Particularly helpful Moodlers Picture of Plugin developers
What you're searching for it's here:

Site administration > Server > Tasks > Task processing > Keep alive time  (https://moodle.org/mod/forum/discuss.php?d=446203#p1793563)

Setting it to 0, you got the cron.php behaviour pre 4.2. However, I would not consider this as a fix, this setting has it's "sense": now those who install moodle should carefully evaluate the balance between compute load and moodle immediacy on task execution.

I read about the main problem of the "unchecked" cron: maybe I'm wrong but i don't think it's related to this. I would try to diagnose the caching level (if any) or the database by reading the contents of mdl_config table AND the contents of mdl_config_log for records where the field name contains cron_enabled.

Average of ratings: Useful (1)
In reply to Hugo Ribeiro

Re: Cron_enabled config goes back to uncheck

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

You said, "cron.php isn't running by cli". Could you paste a screen-shot of the terminal, when you run cron.php in the shell?

As others have pointed out, there may be two issues:
- Caused by MDL-77186: Set Site administration > Server > Tasks > Task processing > Keep alive time to 0 and see whether it helps.

I have initiated the discussion MDL-77186 "Add a keep-alive setting to admin/cli/cron.php", Release 4.2. Effect on performance? in the Hardware and performance forum.

- cron_enabled going back to off. Can't be related to the first one. Or do you have other parameters which won't stay.
In reply to Visvanath Ratnaweera

Re: Cron_enabled config goes back to uncheck

by Hugo Ribeiro -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
It's a rather new install but It seems to be the only setting that doesn't "sick". On the db, the setting is 0, and the config_log shows a bunch of entries changing cron_enabled to 1 (while it always stay as 0).

When I run cron.php in the shell I get "Cron is disabled. Use --force to continue" and it sure continues if I force it.
I thought It could be something related to the php version. I hadn't noticed we were using 8.2. But now we are using 8.1 and we get the same behaviour.
In reply to Hugo Ribeiro

Re: Cron_enabled config goes back to uncheck

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Then the cron settings have changed since 4.1. It has Administration > Security > Site security settings : Cron execution via command line only (cronclionly) and : Cron password for remote access" (cronremotepassword). Sorry, I'm not on 4.2, not even on 4.1 for production. Hope some bleeding-edge admins will report.

Edit: Rel. 4.1 also has Administration > Server > Tasks > Task processing : Enable cron (cron_enabled). That must be the setting that won't stick.
In reply to Visvanath Ratnaweera

Re: Cron_enabled config goes back to uncheck

by Hugo Ribeiro -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Thank you all. I haven't been able to get it to work, but I installed a fresh 4.2 on the same server and found no issues.
While this is very odd, I'm tented to do a fresh install.
In reply to Hugo Ribeiro

Re: Cron_enabled config goes back to uncheck

by Hugo Ribeiro -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Did a fresh installation and everything works fine. Cron is now running.
Thank you