Skip to content

Instantly share code, notes, and snippets.

@shmaltorhbooks
Created May 10, 2013 11:15
Show Gist options
  • Save shmaltorhbooks/5553804 to your computer and use it in GitHub Desktop.
Save shmaltorhbooks/5553804 to your computer and use it in GitHub Desktop.
kill all user processes
<?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