Linux method code to solve PHP timer problems

Source: Internet
Author: User
This article mainly share with you the Linux solution PHP Timer problem method code, PHP is often passive execution, the user sends an HTTP request, the server receives the request to execute, he is very difficult to take the initiative to do something. For a language with no timers or a weak timer in PHP, the Linux task should be used decisively.

The idea is to plan the task, according to the set time to execute the Curl command, or send an HTTP request, since you PHP like passive, let you passive to the end.

1. Create a scheduled task

[Root@izbp17kcgwxvwveyk6c15dz ~]# crontab-ecrontab:installing new Crontab[root@izbp17kcgwxvwveyk6c15dz ~]# crontab- L1 1 1 * *  /phpstudy/mycurl.sh1,11,21,31,41,51 1,2,3,4 1 * *  /phpstudy/mycurldepot.sh5,35 * * * *  /phpstudy/my Curlautocheck.sh[root@izbp17kcgwxvwveyk6c15dz ~]#

Edit Task Crontab-e

View current Task Crontab-l

Detailed command: Click to open link

2.SH File Curl Command

Curl http://127.0.0.1/autocheck.php

3. Specific business logic

Executing in PHP

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.