3 // very basic cron functionality.
4 // later this will go through /mod
5 // and things like auth plugins
6 // but we don't have those yet, so...
8 $starttime = microtime();
10 require_once(dirname(__FILE__
)."/includes.php");
15 mtrace("Server Time: ".date('r',$timenow)."\n\n");
17 $lastcron = $CFG->lastcron
;
18 if (empty($lastcron)) {
22 // we only want to do this once a day because it could take awhile...
23 if ($timenow - (60*60*24) > $lastcron) {
24 mtrace('Cleaning up old incoming files... ','');
25 // clean up the lms incoming files
26 delete_records_select('files_incoming','intentiondate < ?',array(time()-60*60*24));
28 $dirtocheck = $CFG->dataroot
.'temp/lms/';
29 $cmd = "find $dirtocheck -type d -cmin 1440 -print0 | xargs -0 -r rm -rf";
32 $dirtocheck = $CFG->dataroot
.'lms/incoming';
33 // this is not going to work unless this script is running as either the owner of these files
35 $cmd = "find $dirtocheck -type d -cmin 1440 -print0 | xargs -0 -r rm -rf";
42 if ($mods = get_list_of_plugins()) {
43 foreach ($mods as $mod) {
44 $libfile = $CFG->dirroot
.'mod/'.$mod.'/lib.php';
45 if (!file_exists($libfile)) {
48 require_once($libfile);
49 $cronfunction = $mod.'_cron';
50 if (!function_exists($cronfunction)) {
53 // each module is responsible for checking their last runtime and not running again if it's too soon.
54 mtrace('Running cron for '.$mod.'...','');
61 if (!set_config('lastcron',$timenow)) {
62 mtrace('Could not update last cron time to now!');
65 mtrace("Cron script completed correctly");
67 $difftime = microtime_diff($starttime, microtime());
68 mtrace("Execution took ".$difftime." seconds");