php - Php artisan schedule dosen't execute the command
问题描述
so I'am trying to run a task with laravel schedule and php schedule:run works well but it does not execute the command in real
There is my kernel class
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
//$schedule->exec('php artisan migrate:fresh')->everyMinute();
$schedule->command('migrate:fresh')->everyMinute();
}
}
And the result of php schedule:run
Running scheduled command: '/usr/bin/php7.2' artisan migrate:fresh > '/dev/null' 2>&1
解决方案
您需要创建一个 CRON 作业以每分钟运行一次调度程序。
然后,CRON 将每分钟自动触发并运行您在 kernel->schedule 函数中设置的任何命令。
你可以在Laravel 文档的启动调度程序下找到详细信息
推荐阅读
- sql - SQL union all 与 group by
- sql - SQL 链接服务器 - 无法执行过程
- algorithm - 素数算法
- java - 我如何从java中的url中获取特定的单词
- laravel - 从关系中只获取一列
- c# - 使用 Fedex ShipService WSDL 的 C# 中的无效包裹计数或无效包裹序列号
- python - 为什么这个简单计算器的第二版可以正常工作,而第一版却不行?是因为代码中运算符的顺序吗?
- php - DataTables SSP - 列问题
- api - Asterisk API - 从浏览器访问的问题
- graphql - 在 GraphQL 中表示层次类型