Laravel - 当最后使用 OS cron 作业时,计划时间设置的用途是什么?

Laravel - What is the usage of schedule time setting when lastly it uses OS cron job?

Laravel 文档:

          • cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

This Cron will call the Laravel command scheduler every minute. When the schedule:run command is executed, Laravel will evaluate your scheduled tasks and runs the tasks that are due.

我运行这些代码在app\Console\Kernel.php下面:

$schedule->job(new \App\Jobs\done)->everyMinute();
$schedule->command('done:done')->everyMinute();

但其中 none 成功了!所以我 运行 命令 php artisan schedule:run 但它只 运行 一次,每次我想让它触发 job/command 我应该 运行 这个命令所以我试图在 Laravel 文档中使用上面的命令。然而,它并不是每分钟都有效。所以我尝试每 5 分钟在 Task Scheduler 和 运行 中创建一个任务(因为它没有少于 5 分钟)现在它正在工作但是 ->everyMinute() 的使用是多余的,因为Laravel 仅 运行 的时间表,但完成的主要工作是由 Windows 任务计划程序完成的。那么我该如何修复它才能不使用 cron 作业或 windows 任务调度程序?

谢谢

这样你就可以关闭问题了。

正如我在评论/聊天中所说的那样

  • 您应该能够在 Windows 任务计划程序上设置每分钟: http://somoit.net/windows/scheduled-task-every-minute
  • 您也可以在 Windows 任务计划中使用 php artisan done:done 而根本不使用 Laravel 内核。
  • 当您手动 运行 作业时 everyMinute() 被忽略的事实是因为 Laravel 知道 cron 不能每分钟执行一次以上。因此它不会跟踪设置为 everyMinute() 的作业。这意味着,每次你 运行 命令 php artisan schedule:run 它都会 运行 工作。

并且在聊天中提到了@kyslik:官方文档中很好地介绍了调度程序:https://laravel.com/docs/5.7/scheduling#introduction