How do I find and kill a php loop (process)?

Since you were manually running the php binary, either by using php or by using the php shebang at the top of the script, you'll need to find it's PID and kill it.

You can use pkill -9 php or if pkill itsn't present you can use ps -efw | grep php | grep -v grep | awk '{print $2}' | xargs kill to kill all php processes.

In addition if a process is making outgoing network connections to an external API, those connections will show up in a netstat.

You should be able to do a netstat -anop to show you all connections and the PID of the process that controls them. Find out IP/hostname of external API server, find that IP/hostname in the netstat list, kill related PID.


If i understood correctly your Post, you ran a Script from PHP-CGI through your console that it probably something gone wrong and spammed API's Servers.

So There are many possibilities that may caused this problem. First of all, when you are executing a PHP Script just buy typing "php scriptname.php" it waits for PHP Script to end and then is returning to your main Session Input. If you close your shell during the execution of the script it will stop its operation. Unless you started your PHP with a "screen" or "&" there is not a single possibility the script to continue running.

Now lets analyze its operation. If the script gone into an infinite loop , opening a socket, that means that it would try to connect to the API's Server Like hundred times per second. That means that the target server should ban you from the first 10 seconds. Something you haven't clarified to us is, the flowrate of the connection requests to target server. Does the API's Support provided you any more information about that? And if yes what did they said.

Having said that your VPS still sending requests to the Servers i would suggest you to do

ps -A xa | grep php

and check for running php instances. You might accidentaly started a php script in background by adding a & to the end of the line. If this command return something. Find application's pid, and terminate it with the following command

kill -9 pid

If that doesn work , restart your vps and ask them if it still send them connection requests (something that is currently impossible, and that would mean that their firewall placed your packets in slow mode (meaning that it queued them with a delay to their servers))