Cron

Cron

by Alex Martins -
Number of replies: 8

The documentation does not speak in detail about the cron (Schedule this query to run each day (At night)) feature in the Report configuration. Can anyone give more details of the functionality?


Regards,

Average of ratings: -
In reply to Alex Martins

Re: Cron

by Robert Brenstein -
Cron is a standard function on servers and nothing specific to Moodle, hence only generic instructions. Google for cron or check the documentation on your server for details applicable to your environment.
In reply to Alex Martins

Re: Cron

by Randy Thornton -
Picture of Documentation writers

Alex,

You set the hour you wish it to run in Site admin > Plugins > Blocks > Config reports > Settings > Execute at.  And the reports will run at the next scheduled cron job on or after that time.

It will process and run any report where you have checked the "Auto run daily" setting to ON. That setting is found in  the "Report" tab, General section for each report.

Basically it just runs the report so you can then view or export it later without re-running the report. There may be cases where you want to do this for performance reasons or for getting certain data at the end of the day or before the next days processing (for example, to get course completion data at a specific time.)

Randy


Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Cron

by Alex Martins -

Thanks Randy Thornton, is this report information not consumed in real time? And if not, where is this information stored for future reference? Moodledata?

Hugs,

Alex Martins

In reply to Alex Martins

Re: Cron

by Randy Thornton -
Picture of Documentation writers

The report output is updated in real time when you click the View report tab.

Where report output for cron reports lives is a good question.

The report settings, including code, is in the database, in mdl_block_configurable_reports, but I am not sure where the croned output reports are kept.

Moodledata is the likely place. 

This is where the Ad-hoc db queries tool keeps all its report outputs, for instance. It is designed to store and email reports, so all the output files from it are there in csv format. I use to this plugin to do all my timed reports since I can control it better, email them, and also the files are on the server if I need to grab them or save them somewhere else.

Try setting some reports to run via the cron and see where it puts them...

Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Cron

by Randy Thornton -
Picture of Documentation writers

Alex,

It looks like to me it does not save them anywhere. It doesn't save the output that I can see: as far as I can tell the code for the cron function just runs the query, but doesn't do anything else.

Let me know if you find something different.

So I am not really sure it is even useful for what it was designed for. Perhaps people have other uses for it. I guess I am remembering now why I gave up on this a long time ago and put all my scheduled reports in the Ad-hoc db queries plugin instead, which is just what it is designed for.

In reply to Randy Thornton

Re: Cron

by Vicke Denniston -
Picture of Testers

So is there a way to just check when/if cron is running?

If there is a better thread, fell free to point me there

In reply to Vicke Denniston

Re: Cron

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you go to notifications, there will be a message if cron has not run recently.

You can also check your scheduled tasks page and see if they appear to be running correctly.

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: Cron

by Vicke Denniston -
Picture of Testers

Thank you that was exactly what I needed. I was checking Notifications, but that only tells me 24 hours. but the scheduled tasks page is perfect