运行在Apache2上的Laravel版本5.7、PHP7.2版本
我的crontab中的命令如下:
* * * * * php /var/www/dev-site/artisan schedule:run >> /dev/null 2>&1我的内核如下:
<?php
namespace App\Console;
use App\Console\Commands\ImportInvoiceBatch;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
ImportInvoiceBatch::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('import:invoice-batch')->everyMinute()->withoutOverlapping();
}
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}运行我定义的命令"php artisan import:invoice-batch“可以正常工作,甚至运行"php artisan schedule:run”也可以识别所有内容并按预期运行任务,但是调度程序并没有像预期的那样每分钟执行一次。我是不是遗漏了什么?提前谢谢。
发布于 2019-01-08 02:59:58
在运行artisan之前,尝试将工作目录更改为应用程序根目录:
* * * * * cd /var/www/dev-site/artisan && php artisan schedule:run >> /dev/null 2>&1此外,您还可以尝试添加用于调试的输出路径:
* * * * * cd /var/www/dev-site/artisan && php artisan schedule:run >> /var/log/crontab/artisan.log 2>&1https://stackoverflow.com/questions/54077886
复制相似问题