General developer forum

Trouble with Cron.php (Moodle 3.4)

 
Picture of Willowvayle Cornelius
Trouble with Cron.php (Moodle 3.4)
 

Hello everybody!

I'm sure that this is a total noob question, but I'm still fairly new to this portion of web development/maintenance.

I'm having trouble with my scheduled tasks, I assumed that they were running (doing whatever these tasks are supposed to be doing) but when I checked today it showed that nothing has run since the day I discovered I was supposed to have these...


I did some looking up, but I couldn't find anything with a straight answer.

I've attached a screenshot of the Scheduled Tasks page and I am running Moodle 3.4 with PHP 7+ installed (since I saw that some suggested to update, but mine appears to be goo there), and I'm not sure what else I'm supposed to provide.


Thank you all in advance!!!


Scheduled Tasks Page

 
Average of ratings: -
Picture of Jerry Lau
Re: Trouble with Cron.php (Moodle 3.4)
 

did you call the cron script to run either on CLI or through web interface?

 
Average of ratings: Useful (1)
Picture of Willowvayle Cornelius
Re: Trouble with Cron.php (Moodle 3.4)
 

Web interface has been disabled by default, so I plan to keep it that way (they suggest anyway).

I ran the script in CLI back in March, I assumed that would've been enough. Would running it again start the scheduled tasks like they are supposed to?

 
Average of ratings: -
Davo
Re: Trouble with Cron.php (Moodle 3.4)
Core developersParticularly helpful MoodlersPlugin developers

You can't run the cron script once and assume it will all be ok, you need to be running this script regularly, preferably once a minute, all day every day.

Unless you have a lot of spare time to do this manually, I suggest you automate it smile

There are suggestions about how to do this in the documentation: https://docs.moodle.org/en/Cron


 
Average of ratings: Useful (2)
Picture of Willowvayle Cornelius
Re: Trouble with Cron.php (Moodle 3.4)
 
Found it!


I ran the "sudo crontab -u www-data -e" and entered:

*/1 * * * * /usr/bin/php7.0  /path/to/moodle/admin/cli/cron.php >/dev/null


And it worked fabulously!!!


Thank you so much smile


Last thing, what should I have my config.php permissions set to? I originally had 650, but I needed to put to 777 so that cron was allowed to run, so I'm wondering if this could turn into a security issue keeping it open like that?

 
Average of ratings: -
Picture of Willowvayle Cornelius
Re: Trouble with Cron.php (Moodle 3.4)
 
Hm, turns out that I may not have run it correctly as I thought...


I tried running and got a "Permission Error" on config.php.


I changed the permissions temporarily to 777, and now the script is running (I originally had the permissions set to 650).


Was that my problem? If so, what should the permission for my config file be?

 
Average of ratings: -
Picture of Rodrigo Mady
Re: Trouble with Cron.php (Moodle 3.4)
 

Hi guy,

Maybe you set the wrong permission in owner or your permissions is changing with some updates. I don't know but you should read https://www.linux.com/learn/understanding-linux-file-permissions and the step 5 in this https://docs.moodle.org/35/en/Step-by-step_Installation_Guide_for_Ubuntu

Moodle recomends:
sudo chown -R www-data /var/moodledata
sudo chmod -R 777 /var/moodledata
sudo chmod -R 0755 /var/www/html/moodle 

 
Average of ratings: -