laravel中crontab不执行的原因是什么及怎么解决
1.设置 $signature 属性
protected $signature = 'test:change';
2.handle 函数
public function handle()
{
//测试 写入文件 路径使用绝对路径
$handle = fopen("/usr/share/nginx/html/mylaravel/public/xiazai/1.txt","a+");
fwrite($handle,"test
");
fclose($handle);
}/app/Console/Commands/Kernel.php
1. 设置$commands属性
protected $commands = [ test::class, ];
2.schedule函数
protected function schedule(Schedule $schedule)
{
$schedule->command("test:change")->everyMinute();
}原因:php的路径并不识别 或者说 crontab 中使用的php的可执行文件 和在脚本中执行的php文件不一样
执行 whereis php
可以发现 当前有不只一个的php执行文件 发现自己在使用的php路径之后 修改 crontab中的配置
