I have a simple infinite for
loop looking like this:
set_time_limit (0);
for (;;)
{
... //Doing some stuff including to write to a file
sleep(300);
}
It's running on my server. (Shared hosting account)
How on earth can I stop it?
You can press Ctrl + C .
An infinite loop will run forever, but the program can be terminated with the break keyword. In the below example, we will add an if statement to the while loop, and when that condition is met, we will terminate the loop with break .
kill the process. assuming you can get access to the console via ssh and your server runs on linux:
ps -ef | grep php // to get a list of php-processes
kill [process-id] // kill the process by process-id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With