Phpignore_user_abort () to implement the task scheduler function

Source: Internet
Author: User
Tags crontab example
The php Tutorial file implemented by ignore_user_abort () can run after the browser is turned off. let's take a look at this function usage. ignore_user_abort (): will the execution of the script be terminated when the function is set to be disconnected from the client...

Ignore_user_abort () implements the php Tutorial file to run after the browser is closed. let's take a look at this function usage.

The ignore_user_abort () function sets whether the script execution is terminated when the client is disconnected.

This function returns the previous value (a Boolean value) set by user-abort ).
Phpignore_user_abort () to implement the task scheduler function

Syntax
Ignore_user_abort (setting) parameter description
Setting is optional. If it is set to true, the disconnection from the user is ignored. if it is set to false, the script stops running.

If this parameter is not set, the current setting is returned.

Tips and comments
Note: php does not detect whether the user is disconnected until it attempts to send messages to the client. Simply using the echo statement cannot ensure message sending. For more information, see flush.


Of course, to keep the program running, you must add set_time_limit (0 );

Every time we access the php script, we get the returned results after all the php scripts are executed. If we need a script to run continuously, we need to use the php persistent connection method.

Now let's go to the topic.

In linux, there is a simpler method, that is, the crontab command.

The crontab command schedules the execution of some commands at certain intervals.

Crontab usage: crontab [-e |-l |-r] file name-e: edit task-l: Display task information-r: delete scheduled execution task information

Crontab format:
* *** Command
Command to be run by hour, day, month, and week

Crontab example:

*/5 * lynx http://phprm.com
Access phprm.com every 5 minutes

0 8 *** lynx http://phprm.com
Visit phprm.com at every morning

0 10 6*1-5 lynx http://phprm.com
Visit phprm.com on the 6th of each month and from Monday to Friday.

0 5 7 8 * lynx http://phprm.com
Visit phprm.com at on January 1, August 7.

The above special meanings:
"*" Indicates all numbers in the value range, "/" indicates each meaning, and "*/5" indicates every five units, "-" represents a number from a number to a number, "," separate several discrete numbers.

Article address:

Reprint at will ^ please include the address of this 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.