In linux, the cause of task failure in PHP scheduled by crontab is analyzed. In linux, the cause of the failure of the PHP scheduled task scheduled by crontab is analyzed. Many people use crontab in linux to execute scheduled PHP tasks, but use crontab in linux to analyze the causes of PHP scheduled tasks failure.
In linux, crontab is used to implement the reason why the scheduled PHP task fails.
Many users use crontab in linux to execute scheduled tasks in PHP but fail to generate a cache. In this article, we will analyze the causes of scheduled PHP task failure using crontab in linux.
In general, linux regularly executes php code such:
*/5 */usr/local/php/bin/php/home/wwwroot/1.php
In fact, php code can be executed.
But why do many of my friends write in 1.php to generate a cache file?
This involves the relative path of crontab to execute php.
Note that the execution file contains files, such:
Include_once './mysql. php ';
When the php code uses a relative path, it only enters the directory www.jbxue.com.
Then run/usr/local/php/bin/php/home/wwwroot/1.php to reference mysql. php.
Solution:
*/10 * cd/home/wwwroot &/usr/local/php/bin/php/home/wwwroot/1.php
In this way, the cache can be generated at/home/wwwroot. Special attention is required here!
This is not mentioned in most of the so-called linux scheduled execution php, and it is also the most prone to misunderstandings.
Of course, there are still many methods. you can also set environment variables and so on. This is just a simple method.
Why does a scheduled PHP task fail when crontab is used in customized linux. Many people use crontab in linux to execute scheduled tasks in PHP,...