/program/main_cron.php - take care of recurring jobs
This file deals with executing cron jobs. It is included and called from /cron.php.
The work is done in main_cron().
First we look to see if it is already time to do something. Criterion: the current time is >= the time in $CFG->cron_next. If that is the case, we start with calculating the time of the next run by adding $CFG->cron_interval minutes to the current time.
Note: we calculate with minutes of 57 seconds just to have a 5% margin between the system cron clock and our own handling. It might just be enough if cron calls us every 15 minutes (900s) and we schedule the _next_ run for 15 minutes (855s): this gives us 45s to deal with delays (otherwise we have to wait 2 x 15 = 30 minutes for the next run).
After scheduling the next run, we step through all modules and execute any cronjobs there in much the same way (scheduling the next run before executing the current one, etc.).
Note that this cronjob is called from /cron.php. This script could be added to /etc/crontab by adding the following line:
1 * * * * www /usr/bin/php /path/to/cron.php
This will let the PHP CLI interpreter run cron.php one minute after the hour, every hour. Note that the 'www' is the userid to run the script as. (The user running the script must have permissions to read all included PHP-files, including config.php).
Alternatively it is possible to periodically run a cronjob which executes wget which in turn retrieves the cron.php script via the web server, e.g.
31 * * * * mmonte /usr/bin/wget -q http://exemplum.eu/cron.php
to call cron.php every 31 minutes past the hour, every hour. You could suppress any output by adding -q -O /dev/null. See man wget for more information.
Documentation generated on Tue, 28 Jun 2016 19:10:28 +0200 by phpDocumentor 1.4.0