vi SearchPID.php
<?php
$port = $argv[1];
if(!empty($port) && is_numeric($port) ){
$pid = trim(shell_exec("lsof -t -i:".$port));
if(!empty($pid)){
shell_exec("sudo kill -9 ".$pid);
echo "pid : ".$pid." killed which is listened port : ".$port."\xA";
}
else{
echo " [X] no such process found for pid : ".$port."\xA";
}
}
else{
echo " invalid pid \xA";
}
?>
Example
Need to pass the port argument in this example.
for example
>sh KillTask.sh 8088
What it will do is , it will grab the exact pid of the process running on port 8088
Thanks!!!
No comments:
Post a Comment