]> git.mjollnir.org Git - moodle.git/commitdiff
Delete old logs is required
authormoodler <moodler>
Sun, 27 Apr 2003 06:21:15 +0000 (06:21 +0000)
committermoodler <moodler>
Sun, 27 Apr 2003 06:21:15 +0000 (06:21 +0000)
admin/cron.php

index 042de251bdd88c6217cdb61cdde1bce3ac66b549..f41094bf1b1c22f90a2b96ce935c90f51735355d 100644 (file)
@@ -1,15 +1,15 @@
 <?PHP // $Id$
 
-// This script looks through all the module directories for cron.php files
-// and runs them.  These files can contain cleanup functions, email functions
-// or anything that needs to be run on a regular basis.
-//
-// This file is best run from cron on the host system (ie outside PHP).
-// The script can either be invoked via the web server or via a standalone
-// version of PHP compiled for CGI.
-//
-// eg   wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
-// or   php /web/moodle/admin/cron.php 
+/// This script looks through all the module directories for cron.php files
+/// and runs them.  These files can contain cleanup functions, email functions
+/// or anything that needs to be run on a regular basis.
+///
+/// This file is best run from cron on the host system (ie outside PHP).
+/// The script can either be invoked via the web server or via a standalone
+/// version of PHP compiled for CGI.
+///
+/// eg   wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
+/// or   php /web/moodle/admin/cron.php 
 
     $FULLME = "cron";
 
@@ -27,7 +27,7 @@
 
     $timenow  = time();
 
-//  Run all cron jobs for each module
+///  Run all cron jobs for each module
 
     if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
         foreach ($mods as $mod) {
@@ -47,7 +47,7 @@
     }
 
 
-// Unenrol users who haven't logged in for $CFG->longtimenosee
+/// Unenrol users who haven't logged in for $CFG->longtimenosee
 
     if ($CFG->longtimenosee) { // value in days
         $longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
@@ -61,7 +61,7 @@
     }
 
 
-// Delete users who haven't confirmed within seven days
+/// Delete users who haven't confirmed within seven days
 
     $oneweek = $timenow - (7 * 24 * 3600);
     if ($users = get_users_unconfirmed($oneweek)) {
         }
     }
 
+/// Delete old logs to save space (this might need a timer to slow it down...)
+
+    if (!empty($CFG->loglifetime)) {  // value in days
+        $loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
+        if (!delete_records_select("log", "time < '$loglifetime'")) {
+            echo "Error occurred while deleting old logs! (before $loglifetime)";
+        }
+    }
+
     echo "Cron script completed correctly\n";
 
     $difftime = microtime_diff($starttime, microtime());