Programmer-How do I schedule a PHP program without planning tasks on Linux or Windows?

Source: Internet
Author: User
How do I schedule a PHP program without planning tasks on Linux or Windows?

Reply content:

How do I schedule a PHP program without planning tasks on Linux or Windows?

If you don't use an external timer, there are only two ways to do it.
1, start a PHP process has been running in the background, do a timer, check that there is no task should be executed
2, through the user in the foreground to fire events, there is user access, then go to check if there is no need to perform the task

PS, in what circumstances will the need for this egg ache be met?

PHP page (that is, can be accessed through the web), can be used third-party web monitoring, the shortest five minutes.

Or I can't figure out what kind of environment can not use crontab.

PHP cannot reside in memory unless you are running on the command line. Therefore, if it is a web-run PHP, it is not possible to implement this function.

Our company's wonderful practices, using the digital browser's automatic refresh feature.

ignore_user_abort();set_time_limit(0);

In the program, the while (true) loop is passed and the time is judged, it is executed.
For ease of control, you can also read a file, if the file is 0 exit, so you can modify the file content to control the process end.

  • Related Article

    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.