- Ignore_user_abort (); PHP scripts can continue to execute even if the client disconnects (such as turning off the browser).
- Set_time_limit (0); Execution time is unlimited, php default execution time is 30 seconds, through Set_time_limit (0) can allow the program to execute indefinitely
- $interval =60*5; Run every 5 minutes
- do{
- $fp = fopen (' test.txt ', ' a ');
- Fwrite ($fp, ' test ');
- Fclose ($FP);
- Sleep ($interval); Wait 5 minutes
- }while (TRUE);
- ?>
Copy CodeJust run the page above and then turn it off, and the program will run all the way down. There are simpler crontab commands in Linux. The function of the crontab command is to schedule execution of some commands at certain intervals. Crontab How to use: crontab [-e |-l |-r] FileName-E: Edit Task-L: Show task Information-r: Delete scheduled execution task information CRONTAB Format: * * * * * * command time, day and month to run commands Examples of crontab:
*/5 * * * * Lynx http://bbs.it-home.org
- Access once every 5 minutes bbs.it-home.org
0 8 * * * Lynx http://bbs.it-home.org
- 8 visits to bbs.it-home.org every morning.
0 6 * 1-5 Lynx http://bbs.it-home.org
- 6th on each month and 10 in the morning of Monday to Friday of each week visit bbs.it-home.org
0 5 7 8 * Lynx http://bbs.it-home.org
- August 7 Morning 5 Visit bbs.it-home.org
Copy CodeExplanation: "*" stands for all values within the range of numbers, "/" stands for each meaning, "*/5" represents every 5 units, "-" represents a number from one digit to a number, "," separates several discrete numbers. This article transferred from: HTTP://HI.BAIDU.COM/ANDYLU1988/ITEM/9674D31406ED61008EBDE4B6 |