2017-03-07 136 views
1

因此,我设置了我的内核文件来安排命令,每天凌晨2点运行。Cron作业未运行Laravel 5.3

class Kernel extends ConsoleKernel 
{ 
/** 
* The Artisan commands provided by your application. 
* 
* @var array 
*/ 
protected $commands = [ 
    Commands\Users\MyCommand::class 
]; 

/** 
* Define the application's command schedule. 
* 
* @param \Illuminate\Console\Scheduling\Schedule $schedule 
* @return void 
*/ 
protected function schedule(Schedule $schedule) 
{ 
    $schedule->command(Commands\Users\MyCommand::class) 
     ->dailyAt('02:00'); 
} 
} 

予由该文档的建议也在命令行运行此:

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1 

,当我在命令行运行“人员MY命令名PHP”命令执行。另外,当我使用schedule:在正确的时间运行命令也运行。

但是,我希望它能够在指定的时间自动运行,并且不会发生。

回答

0

/path/to/artisan应该是Artisan的实际路径。通常像/home/myUser/laravel/artisan或您的Laravel/Artisan在您的安装位置。

1

你有这个命令添加到您的cron作业

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1 

要编辑cron作业,键入此命令第一

crontab -e