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