[100] All PHP daemon processes are stuck? You need to write a daemon. I checked the information ~ Ignore the user disconnection ignore_user_abort (true) in two Tests; ignore the timeout value set_time_limit (0); while (true) {& nbsp; $ logContentdate (Y-m-d & #160; H: I: s ). & quot; [100] All PHP daemon processes are stuck?
You need to write a daemon. I checked the information ~ Just write two lines for testing.
// Ignore user disconnection
Ignore_user_abort (true );
// Ignore timeout
Set_time_limit (0 );
While (true)
{
$ LogContent = date ('Y-m-d H: I: s'). "\ r \ n ";
File_put_contents('log.txt ', $ logContent, FILE_APPEND );
Sleep (10 );
}
This is the current time written into the log file every 10 seconds. However, when this item is executed, it is found that the whole apache will not respond. For example, this is written in a. php, and all other B. php files are useless. Apache seems to be stuck. Want to know what the situation is?
------ Solution --------------------
Only your lines of code won't show what you said
------ Solution --------------------
# Vi log. php
$ LogContent = date ('Y-m-d H: I: s'). "\ r \ n ";
File_put_contents('log.txt ', $ logContent, FILE_APPEND );
?>
# Crontab-e
*/10 */usr/local/php/bin/php log. php
-------------------------------------------------------
Php file write absolute path
------ Solution --------------------
Windows
> Notepad log. bat
# {Your-php-bin-path} php log. php
> Schtasks/create/SC minute/mo 10/tn "php-date-log"/tr log. bat
------ Solution --------------------
The server restricts the possibility of a single process
Switch to Firefox to open a, Google to open B
Do not use ie kernel browsers...
------ Solution --------------------
It is reasonable to say that this problem will not occur. You can try to change the duration.
Also, we recommend that you use scheduled tasks in windows and cron in linux to implement scheduled execution in PHP. In addition, this method is ineffective when the computer is restarted or apache is restarted. you need to run the code again to continue execution.