Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jun 25, 2023
1 parent f63b596 commit 2dd0cf5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bin/reboot.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@
shell_exec($rebootCmd);
} else {
shell_exec($rebootCmd);
}

// 执行 lsof 命令并查找 9502 端口
$output = shell_exec('lsof -i :9502 | grep LISTEN | awk \'{print $2}\'');

// 将进程 ID 转换为数组
$pidList = explode("\n", trim($output));

// 遍历进程 ID 列表并杀死相应进程
foreach ($pidList as $pid) {
if (is_numeric($pid)) {
shell_exec("kill -9 $pid");
echo "进程 $pid 已杀死\n";
}
}

0 comments on commit 2dd0cf5

Please sign in to comment.