search

Home  >  Q&A  >  body text

Laravel task scheduling

Recently, I used Laravel to do scheduled tasks. I wrote a scheduled task that can be executed normally every minute. However, when it is changed to hours, it cannot be executed as expected. It made me confused.

protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
            //DB::table('cms_articles')->delete();
            DB::update('update cms_articles set hit=hit + FLOOR(1 + (RAND() * 10)) where hit>1000');
            DB::update('update cms_articles set hit=hit + FLOOR(1 + (RAND() * 20)) where hit<1000');
        })->hourly();
    }
習慣沉默習慣沉默2789 days ago642

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:53:20

    Please paste the specific code

    reply
    0
  • Cancelreply