how detect stop or running a php script from out and background

半世苍凉 提交于 2019-12-11 06:28:59

问题


I have this code:

<?PHP
ignore_user_abort(true);
set_time_limit (0);

while(1) {

    // my codes

}
?>

now After a while how to detect that 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 must write status of itself and if Suddenly stopped (such as server reset or occuring an error in script) will not write any status and we cant detect status of it such as is stopped or runnig.

now I want know that how can I detect runnig status of a script from out?

and how can I stop it from out?

来源:https://stackoverflow.com/questions/17721640/how-detect-stop-or-running-a-php-script-from-out-and-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!