Laravel 5.3 - 计划任务无效

时间:2016-11-02 17:10:41

标签: php laravel cron

我试图每天运行一个cron函数,但它没有被执行。我已经设置了用于执行它的artisan命令和cron计划任务,artisan命令正在运行但计划任务不起作用。这就是我在Kernel.php中设置的方式:

protected function schedule(Schedule $schedule)
{
    $schedule->command('import:issues')
      ->withoutOverlapping();

    $schedule->call('App\Magazine\Services\MagazineService@import')
      ->dailyAt('00:00');
}

然后在MagazineService中我有一个功能

public static function import()

这是我有命令设置的文件:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Magazine\Services\MagazineService;

class IssuesImport extends Command
{
    /**
    * The name and signature of the console command.
    *
    * @var string
    */
    protected $signature = 'import:issues';

    /**
    * The console command description.
    *
    * @var string
    */
    protected $description = 'Imports magazine issues';

    /**
     * The Magazine service.
     *
     */
    protected $magazines;

    /**
    * Create a new command instance.
    *
    * @return void
    */
    public function __construct(MagazineService $magazines)
    {
      parent::__construct();
      $this->magazines = $magazines;
    }

    /**
    * Execute the console command.
    *
    * @return mixed
    */
    public function handle()
    {
      $this->magazines->import();
    }
}

0 个答案:

没有答案