Many people use crontab to implement PHP to perform timed tasks under Linux and fail to generate the cache. This paper analyzes the reasons of using crontab to realize scheduled PHP task failure in Linux.
Generally we Linux regularly execute PHP code such as:
*/5 * * * */usr/local/php/bin/php/home/wwwroot/1.php
In fact, this is possible to execute PHP code.
But why do many friends write in 1.php to generate a cache file that is not generated?
This involves crontab the relative path of PHP execution .
Note In the execution file, there are files that are included, such as:
When using a relative path in PHP code, you only have to go to that directory.
Then execute/usr/local/php/bin/php/home/wwwroot/1.php to reference mysql.php to take effect.
Here's how to fix it:
*/10 * * * * cd/home/wwwroot &&/usr/local/php/bin/php/home/wwwroot/1.php
also this way the cache can be generated in/home/wwwroot. Special attention is needed here!
This is mostly written by the so-called Linux timed execution PHP is not mentioned, but also the most prone to misunderstanding.
Of course there are a lot of methods, you can set environment variables and the like. This is just a simple method.
http://www.bkjia.com/PHPjc/824602.html www.bkjia.com true http://www.bkjia.com/PHPjc/824602.html techarticle Many people use crontab to implement PHP to perform timed tasks under Linux and fail to generate the cache. In this paper, the use of Linux under the crontab implementation of scheduled PHP task failure reasons to do an analysis ...