I have a long running PHP script that looks something like this:
$myClass->myFunction('this takes 30 minutes to run');
I want to send a heartbeat every 30 seconds during the running of myFunction()
to alert my application that the script is still running and did not fail.
In JavaScript, I can achieve this with setInterval()
. I want to be able to do the same thing in PHP. Perhaps with a custom setInterval()
function that looks like:
setInterval(function(){
$myClass->addHeartbeat("still running");
}, 30000);
Is this possible given the synchronous nature of PHP?