]> andersk Git - sql-web.git/blobdiff - cron/checkProcesses.php
cron scripts dont run if offline
[sql-web.git] / cron / checkProcesses.php
index b5c1554d0681fb14e64a4d4d4c5b6a709a923002..c88131f5f51fdb7af8db9dc94da18382f2e3b375 100755 (executable)
@@ -3,7 +3,9 @@
 @chdir(dirname(__FILE__).'/../');
 require_once('mitsql.cfg.php');
 require_once('mitsql.lib.php');
-define('MAX_PROC_TIME', 10);
+isOffline() && exit;
+
+define('MAX_PROC_TIME', 20);
 
 $baddbs = $badusers = $bad = array();
 $result = mysql_query('SHOW FULL PROCESSLIST');
@@ -21,7 +23,6 @@ foreach($bad as $badproc) {
        $baddb = mysql_escape_string($badproc['db']);
        $badtime = $badproc['Time'];
        $badquery = $badproc['Info'];
-       mysql_query('KILL '.$badproc['Id']);
        if (empty($baddb)) continue;
        $sql = "SELECT User.UserId,User.Name,User.Email
                        FROM `User`
@@ -33,6 +34,7 @@ foreach($bad as $badproc) {
                $mailtos[] = $addy['Email'];
                $mailnames[] = $addy['Name'];
        }
+       if (empty($mailtos)) continue;
        $mailto = implode(', ',$mailtos);
        $mailname = implode(', ',$mailnames);
        $mailsubj = "[sql] Slow Query on $baddb";
@@ -52,7 +54,7 @@ This SQL Service is available at sql.mit.edu.
 
 $badquery";
 
-       $mailto = 'jwp@mit.edu';
+       mysql_query('KILL '.$badproc['Id']);
        mail($mailto,$mailsubj,$mailbody,"From: SQL Service <sql@mit.edu>\r\nBcc: sql@mit.edu\r\n");
 }
 
This page took 0.138392 seconds and 4 git commands to generate.