Cron作业无法使用Nanobox在Lumen上运作

时间:2018-07-13 20:58:22

标签: laravel cron scheduler lumen

我正在尝试在nanobox中编写cron作业。我已经在Kernel.php中实现了一些逻辑,并对boxfile.yml文件进行了相应的更改。此后,我的计划作业预计将每小时运行一次,但不会运行。我不知道我在这里想念什么。

我的boxfile.yml的相关部分如下所示

  cron:
    - id: scheduleForRSS
      schedule: '0 * * * *'
      command: 'php artisan schedule:run'

我的Kernel.php文件具有以下课程

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->call(function () {
            //DB::table('keyword')->delete();
            echo "Hello, from Kernel.schedule !";
            DB::table('xyz')->insert([
                ['title' => 'abc', 'value' => 0]            
            ]);
        })->everyMinute();
    }
}

但是,当我运行以下命令时,调度功能被调用,并且可以在控制台上看到输出以及将记录插入DB中,证明该功能已正确实现并执行了应做的事情。就是这样,由于某种原因,它没有被nanobox的cron作业功能调用。

/app $ *php artisan schedule:run*

Running scheduled command: Closure
Hello, from Kernel.schedule !

1 个答案:

答案 0 :(得分:0)

得到排序后,cron-jobs不会在本地计算机上运行。当我将其部署在服务器上(以我的情况为例)时,作业开始运行。