I have a PHP script which will run 24/7 on a VPS with an infinite loop, but problem is that how can I break the infinite loop in php script when desired in order so that the script exists properly?
I know I can kill the process, but if I kill then script will stop immediately and my loop size is very big and if at time of killing the process the execution of is somewhere in middle of loop then the rest half of loop would not be executed and it will create bugs. Also I have some code after loop so if process gets killed then that code would not be executed.
So my question is that how to break a infinite loop of a PHP script running in background when desired without killing the process?