Create PHP timing tasks for Linux
All the following prerequisites are that the server has a PHP environment
First create a php file: the example content is as follows:
<?php $ch=curl_init(); //Set requestcurl_setopt($ch,CURLOPT_URL,"Write the URL to be requested"); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); $output=curl_exec($ch); curl_close($ch); echo date("Y-m-d H:i:s",time())."_".$output."\r\n";
Then give the file executable permissions: chmod +x
Then modify the file for the execution of the timing task: use the command line: crontab -e to open the timing task file and add:
30 17 * * * /usr/bin/php -f /home/task/ >> /home/task/
Explain the concept of time, for example, as above, this is equivalent to performing tasks at 17:30 every day. After completing the above, you can start the scheduled task, use the command line:
service cron start
The above can enable this PHP timing task, and the return value of echo will be written to the file.
Thank you for reading, I hope it can help you. Thank you for your support for this site!