The thinkphp framework uses Linux crontab to write timed scripts for PHP

Source: Internet
Author: User
This article is to share the content is the thinkphp framework with Linux crontab write php timing script, the need for friends can refer to

Within PHP, the path to the Curl TP framework is available, and the PHP is set to Crontab
For example, the access address for TP is Http://www.tp.com/index.php?m=admin&c=controller&a=action
Write a PHP, for example tpcrontab.php

The contents are as follows:

<?php    $url = ' http://www.tp.com/index.php?m=admin&c=controller&a=action ';    $timeout =;    $data = Array ();    $header = Array ();    $ch = Curl_init ();      curl_setopt ($ch, Curlopt_ssl_verifypeer, false); Skip certificate Check      curl_setopt ($ch, Curlopt_ssl_verifyhost, true);  Check that the SSL encryption algorithm exists      curl_setopt ($ch, Curlopt_url, $url) from the certificate;      curl_setopt ($ch, Curlopt_httpheader, $header);      curl_setopt ($ch, Curlopt_post, true);      curl_setopt ($ch, Curlopt_postfields, Http_build_query ($data));      curl_setopt ($ch, Curlopt_returntransfer, true);       curl_setopt ($ch, Curlopt_timeout, $timeout);   Curlopt_timeout sets the maximum number of seconds that curl allows to execute       $response = curl_exec ($ch);        if ($error =curl_error ($ch)) {die          ($error);      }      Curl_close ($ch);     Echo $response;

Reference article: https://bbs.csdn.net/topics/390805964

https://blog.csdn.net/qq_35979073/article/details/79352450

Related 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.