Linux Create PHP Timer task Example Explanation

Source: Internet
Author: User

All of the following are prerequisites for server presence in PHP environment

First create a PHP file: The sample content is as follows:


1 <?php
2 $ch =curl_init ();
3//Setup Request
4 curl_setopt ($ch, Curlopt_url, "write the URL to request");
5 curl_setopt ($ch, curlopt_returntransfer,1);
6 curl_setopt ($ch, curlopt_header,0);
7 $output =curl_exec ($ch);
8 Curl_close ($ch);
9 echo Date ("Y-m-d h:i:s", Time ()). " _ ". $output." \ r \ n ";

Then give the file executable permissions: chmod +x demo.php

Then modify the file that the timer task executes: Use the command line: CRONTAB-E to open the scheduled task file, add:
1 * * */usr/bin/php-f/home/task/crontab.php >>/home/task/task.log.www.laomulu.com/

Explain the concept of time, such as above, which is equivalent to 17:30 points per day to perform tasks. Complete the above to open the scheduled task, using the command line:
1 service cron Start

This will open the PHP timer task, and the Echo return value will be written to the Task.log file.

Linux Create PHP Timer task Example Explanation

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.