Php scheduled task: ignore_user_abort in php implements scheduled task

Source: Internet
Author: User
Php plan task: implement the ignore_user_abort implementation plan task in php-Linux general technology-Linux programming and kernel information. The following is a detailed description. Function-ignore_user_abort. This function can help us implement scheduled tasks like cron in linux. Let's take a look at how to implement it.

First, let's take a look at the php Manual's explanation of this function.

Description
Int ignore_user_abort ([bool $ setting])
Sets whether a client disconnect shocould cause a script to be aborted.

That is to say, the following program will be executed no matter whether the client closes the browser.

Let's look at its parameters.

Parameters

Setting
If not set, the function will only return the current setting.

This function accepts a parameter to determine whether to enable the ignore_user_abort function.

Let's look at the returned values:

Return Values
Returns the previous setting, as a boolean.

Here, the previous setting is returned and bool is worth it. After my test, this statement is incorrect. The returned result is of the int type, if you don't believe it, you can write a PHP file to test it.

After talking about this, how should we use the php function to implement the scheduled task? This function is set_time_limit. You can use set_time_limit0 to set the program execution time to no limit. The default php Execution time is 30 seconds, and set_time_limit (0) the program can be executed without limit. Before executing the program, add ignore_user_abort (1) and set_time_limit (0). How can I write the final program? Here is an example.
QUOTE:

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.