donglei_0507 2016-05-30 19:30
浏览 50
已采纳

Laravel 5.2调度程序

Dear Stackoverflowers,

I've created 2 Laravel commands, one that clears the db of records, an the other one that sends an email.

If I call them separately they work, and in the app/console/kernel.php file I have this:

protected function schedule(Schedule $schedule)
{
    // minute, hour, day of month, month, day of week
    // *, *, *, *, * elke minuut

    $schedule->command('item:removeChecked')->everyMinute();

    $schedule->command('email:sendList')->everyMinute();
}

So when I run the php artisan schedule:run command, it runs the 2 commands immediately and responds with the following:

Running scheduled command: '/usr/bin/php' 'artisan' item:removeChecked > '/dev/null' 2>&1 &
Running scheduled command: '/usr/bin/php' 'artisan' email:sendList > '/dev/null' 2>&1 &

But then it stops and does nothing.

So my question is how could I get this to work? I cant find any good documentation about this paret of Laravel, probably because it's quite new.

Thanks in advance for helping me.

Theo.

  • 写回答

1条回答 默认 最新

  • douyalin0847 2016-05-30 19:38
    关注

    You have to add an cron job.

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

    https://laravel.com/docs/5.2/scheduling#introduction

    Rémon

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端