Scheduled tasks class and cron jobs

Scheduled tasks class and cron jobs

by Ben Laor -
Number of replies: 3

I recently needed to integrate an already existing system into a new server.
When approaching scheduled tasks and cron tasks, the previous developer would run on their server a custom cron (lets call it "Sync1.php").
I added a cron task on my own server for Sync1.php and added a task for the default Moodle cron.php
And now i notice that the code in Sync1 is executed after the cron task for it is run, and a second time when the default Moodle cron.php is run
After further investigation i found that in the list of scheduled tasks in Moodle there is another task that seems to be for the same Sync, but is named differently (lets call it Sync2) and after looking in the code for the whole Moodle system i wasn't able to find Sync2 as a class (from my understanding you need to define it as a class inheriting the "scheduled_task" class)

How come the default Moodle cron.php file knows to run my Sync1?
What is the meaning of Sync2 if there is no class defined for it in the system?

Average of ratings: -
In reply to Ben Laor

Re: Scheduled tasks class and cron jobs

by Ben Laor -
After some more research i found that it does indeed run from the scheduled tasks (i found the class) and that the code it executed looked similar but was actually from a different file than Sync1.
all is well now smile
In reply to Ben Laor

Re: Scheduled tasks class and cron jobs

by sulagna behera -

Hi Ben,

I'm working on moodle 3.3 on windows. I have been trying to get the course completion status. 

The regular_completion_data cron job seems to have some kind of issue. It only runs when done manually. I have tried setting it up to run every minute, it doesnt. Sometimes manually running the cron,  the completion data doesn't updated.


Could you please help me out?


Regards,

Sulagna

In reply to sulagna behera

Re: Scheduled tasks class and cron jobs

by Ben Laor -

Do you have access to your server's management system? If so, you can create a custom cron job to run a file (which you will write) and in that php file, require/include the file that contains the method that is run on "regular_completion_data" and tell it to run every minute.