Implementation of PHP scheduled task execution

Source: Internet
Author: User
PHP is relatively weak in this regard. if you only use php to implement it, you can: & amp; lt ;? Phpignore_user_abort (); // after closing the browser, run the php code set_time_limit (0

PHP is relatively weak in this regard. if you only use php, you can implement the following:


 

But when I execute the script, even if I close the browser, I cannot stop this program at all, so you need a script execution switch, you can use the method introduced by external files to implement the include switch variable during the while loop. Then we can achieve this:

Create an external variable file switch. php with the following content:

Return 1; // 1 run the script 0 exit the execution script

?>

The script for improvement is as follows:


 

This script is only feasible for testing and should be less efficient. for lamp, you can use crontab to implement it. I will post a tutorial later.

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.