Page to kill all user's processes?
Hello,
We are trying to create a cpanel page that the user can run to kill all their running processes.
First, here is what we have to show all the user's currently running processes:
[PHP]header( "Show Current Processes" );
?>
";
echo "
";
$cmd = "ps -U ".$user." -u ".$user." --format pid,vsz,pmem,pcpu,start_time,etime,cmd";
system($cmd);
echo "";
?>
footer();
$cpanel->end();
?>
[/PHP]
We put that into a "test.live.php" file, and it works when called directly from the user's cpanel. (Just manually type it into the browser URL bar.)
But then we want to give the user the ability to kill their own account's processes, so we created this... which does NOT work:
[PHP]
) && ($_GET["task"> == "killall")) {
$cmd = "killall --user " . $user;
//$cmd = "pkill -U " . $user;
echo $cmd;
echo "";
echo "All running processes for your hosting account have been terminated.";
echo "
";
echo "";
echo 'Show all currently running processes for your web hosting account.';
echo "
";
exec($cmd);
}
?>
footer();
$cpanel->end();
?>
[/PHP]
It seems the "exec($cmd);" code does not properly execute. We've tried system() and passthru(), but neither of those work either.
Any ideas how to make this work, so the user can kill their own processes?-
Hello, The issue with killing all processes associated with the user is that it's going to kill the cPanel process associated with the request to the page. This will lead to an error message such as: Child failed to make LIVEAPI connection to cPanel.
Can you try updating the second script so that ignores the cPanel related processes (e.g. processes starting with cpaneld, /usr/local/cpanel/3rdparty/php/56/bin/php-cgi, or /usr/local/cpanel/cpanel)? Thank you.0
Please sign in to leave a comment.
Comments
1 comment