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

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog