It's not the very best solution, but I've used it a couple of times when
I needed to do it quick without to much trouble. Make not I kill all the
processes, on my server px -x will only return like 4 times /sbin/apache
and it's pretty safe to kill them without any trouble.
-
-
-
-
-
-
-
-
-
-
-
-
- class KillAllProcesses {
-
-
-
- function killallprocesses() {
- $this->listItems();
- }
-
-
-
-
- function listItems() {
-
-
-
-
-
-
-
-
-
- $output = shell_exec('ps -x');
-
- $this->output($output);
-
-
- $array = explode("\n", $output);
-
- $this->doKill($array);
- }
-
-
-
-
-
- function output($output) {
- print "
"
.$output."";
- }
-
-
-
-
-
-
- function doKill($array) {
-
-
-
-
-
- for ($i = 1; $i < count($array); $i++) {
- $id = substr($array[$i], 0, strpos($array[$i], ' ?'));
- shell_exec('kill '.$id);
- }
- }
- }
- new KillAllProcesses();
- ?>
阅读(871) | 评论(0) | 转发(0) |