What to do with the delayed execution program

Source: Internet
Author: User
About the delay execution program
There is a program like this, I want to execute a program every minute, this PHP idea is how, how to write it
For example, for (i=0;i<1000;i++) {
Program logic
Here want to delay a minute to execute and then proceed to the next cycle, how do you write this or ideas, as if the PHP page has a specified time to timeout
}
------Solution--------------------
You're going to keep this page open,
Set_time_limit (0); You can make the page do not time out
Sleep (60); You can let the program sleep here for 60 seconds after the execution.

But it is not recommended to do this, mainly to see your logic, if it is to walk every minute. It is recommended to do it with crontab.
In the terminal input

Crontab-e
* * * * * * php handle.php >> handle.log
: Wq


  • 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.