Created
May 10, 2013 11:15
-
-
Save shmaltorhbooks/5553804 to your computer and use it in GitHub Desktop.
kill all user processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$params = $_SERVER['argv']; | |
if (!$params[1]) | |
die("Enter user name...\n"); | |
$link = mysql_connect('IP', 'UserName', 'Pwd'); | |
if (!$link) { | |
die('Could not connect: ' . mysql_error()); | |
} | |
echo "Connected successfully\n"; | |
$result = mysql_query("SHOW FULL PROCESSLIST"); | |
$globalKill = 0; | |
while ($row = mysql_fetch_array($result)) { | |
$process_id = $row["Id"]; | |
if ($row["User"] == $params[1]) { | |
$sql = "KILL $process_id"; | |
mysql_query($sql); | |
$globalKill++; | |
} | |
} | |
echo "Killed $globalKill\n"; | |
mysql_close($link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment