[100] All PHP daemon processes are stuck? What should I do?

Source: Internet
Author: User
[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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.