dongsong4418 2018-11-19 07:52
浏览 63
已采纳

Laravel - 最后使用OS cron作业时,调度时间设置的用法是什么?

Laravel docs:

          • 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.

I run these codes below in app\Console\Kernel.php:

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

but none of them worked! so I run the command php artisan schedule:run but it runs only once and each time I want to make it trigger the job/command I should run that command so I tried to use the command above in Laravel docs. However again it didn't work every minute. So I tried to create a task in Task Scheduler and run it every 5 minutes(because it didn't have less than 5) now it's working but the usage of ->everyMinute() is redundant because the schedule of Laravel only runs but the main job that is done is by Windows Task Scheduler. So how can I fix it in order not to use cron job nor windows task scheduler?

Thanks

  • 写回答

1条回答 默认 最新

  • douye4254 2018-11-19 11:09
    关注

    Just so you can close the question.

    As I said in the comments / chat

    • You should be able to set every minutes on Windows Task Scheduler: http://somoit.net/windows/scheduled-task-every-minute
    • You can also use php artisan done:done in your Windows Task Schedule and not use the Laravel Kernel at all.
    • For the fact that everyMinute() is ignored when you run the job manually is because Laravel know that a cron can't be executed more than once a minute. So it doesn't keep a trace for a job set to everyMinute(). This mean, every time you run the command php artisan schedule:run it will run the job.

    And has @kyslik mentioned in the chat : The scheduler is well covered in the official documentation: https://laravel.com/docs/5.7/scheduling#introduction

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

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮