How to detect stopping or starting PHP script from background and background
I have this code:
<?PHP
ignore_user_abort(true);
set_time_limit (0);
while(1) {
// my codes
}
?>
now After a while, how to detect if the script is running yet or not?
I used this role for this question:
<?PHP
ignore_user_abort(true);
set_time_limit (0);
while(1) {
// my codes
$statusfile = strtolower(file_get_contents('status.txt')); // for stop checking
if (!(strpos($statusfile,'stop') !== false)) break;
$status = /* my status */; // for writing status of itself
file_put_contents('status.txt', $status);
}
?>
but in this role, my script itself has to record the status of itself, and if it stopped suddenly (for example, the server is reset or there was an error in the script), it will not write any status, and we cannot define its status as stopped or started.
now i want to know how can i determine runnig status from script from out?
and how can i stop it?
+1
source to share
No one has answered this question yet
See similar questions:
or similar: