I've written a nice script which runs the following on the command line, and then parses the output into a table:

SHOW FULL PROCESSLIST

Pretty much looks like:

exec("mysqlstuff -e SHOW FULL PROCESSLIST", $output_array);

But I'm able to extract the process ID from the return. Then I've added a little form that will, hopefully, allow the user to issue a command to the server along the lines of:

exec("mysqlstuff -e \"KILL <$processID>;\"");

But that just doesn't work. It returns absolutely nothing; even if I put an "echo" in front of that code, I get nothing.

Is this a permission error? I know that php doesn't have that many permissions to change around the server when run from the web. Also, if I only have readonly access to the database, could that be the culprit? But, if that was the problem, wouldn't I be getting some error of some kind?

Can you guys recommend any tests I can run that might shed some light on this situation? Thanks!

-Aaron

    its likely that your connection doesn't have enough privileges to run the action....

    <?//kill_long_query.php
    //################ //
    
    set_time_limit(30000); 
    
    $result=mysql_query("show processlist"); 
    
    while ($row=mysql_fetch_array($result)) 
    { 
    $process_id=$row["Id"]; 
    if (($row["Time"] > 100 ) || ($row["Command"]=="Sleep") ) 
    { 
    print $row["Id"]; 
    $sql="kill $process_id"; 
    mysql_query($sql); 
    } 
    
    } 
    //###################//
    ?>
    

      I really need to do this from the command line, since I can't connect to the database using mysql_connect() -- very specific network configurations.

      Any way I can figure out what isn't working?

      Thanks.

        Write a Reply...