Home >Backend Development >PHP Tutorial >Use Linux crontab to write PHP timing scripts in the thinkphp framework
The content of this article is to use Linux crontab to write PHP timing scripts in the thinkphp framework. Friends in need can refer to
Just find the path of the curl tp framework in PHP. Then set this php to crontab
For example: the access address of tp is http://www.tp.com/index.php?m=admin&c=controller&a=action
Write a php, for example tpcrontab.php
The content is as follows:
<?php $url = 'http://www.tp.com/index.php?m=admin&c=controller&a=action'; $timeout = 60; $data = array(); $header = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_URL, $url); 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 设置cURL允许执行的最长秒数 $response = curl_exec($ch); if($error=curl_error($ch)){ die($error); } curl_close($ch); echo $response;
Reference article: https://bbs.csdn.net/topics/390805964
net/qq_35979073/article/details/79352450
The above is the detailed content of Use Linux crontab to write PHP timing scripts in the thinkphp framework. For more information, please follow other related articles on the PHP Chinese website!