Kernel.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Console;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  5. use App\Jobs\FiveSecondTaskJob;
  6. class Kernel extends ConsoleKernel
  7. {
  8. /**
  9. * Define the application's command schedule.
  10. *
  11. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  12. * @return void
  13. */
  14. protected function schedule(Schedule $schedule)
  15. {
  16. // $schedule->command('inspire')->hourly();
  17. // $schedule->job(new FiveSecondTaskJob)
  18. // ->cron('*/5 * * * * *') // 每秒的第0,5,10,15...秒执行
  19. // ->withoutOverlapping() // 防止重复执行
  20. // ->name('five-second-task') // 给任务起个名字
  21. // ->onOneServer(); // 如果在多服务器环境
  22. }
  23. /**
  24. * Register the commands for the application.
  25. *
  26. * @return void
  27. */
  28. protected function commands()
  29. {
  30. $this->load(__DIR__.'/Commands');
  31. require base_path('routes/console.php');
  32. }
  33. }