• <tfoot id='3FwlL'></tfoot>
    1. <i id='3FwlL'><tr id='3FwlL'><dt id='3FwlL'><q id='3FwlL'><span id='3FwlL'><b id='3FwlL'><form id='3FwlL'><ins id='3FwlL'></ins><ul id='3FwlL'></ul><sub id='3FwlL'></sub></form><legend id='3FwlL'></legend><bdo id='3FwlL'><pre id='3FwlL'><center id='3FwlL'></center></pre></bdo></b><th id='3FwlL'></th></span></q></dt></tr></i><div id='3FwlL'><tfoot id='3FwlL'></tfoot><dl id='3FwlL'><fieldset id='3FwlL'></fieldset></dl></div>
          <bdo id='3FwlL'></bdo><ul id='3FwlL'></ul>

        <small id='3FwlL'></small><noframes id='3FwlL'>

        <legend id='3FwlL'><style id='3FwlL'><dir id='3FwlL'><q id='3FwlL'></q></dir></style></legend>

        Laravel 5 计划不起作用

        Laravel 5 schedule not working(Laravel 5 计划不起作用)

          <small id='LWJ7p'></small><noframes id='LWJ7p'>

          • <bdo id='LWJ7p'></bdo><ul id='LWJ7p'></ul>
            1. <legend id='LWJ7p'><style id='LWJ7p'><dir id='LWJ7p'><q id='LWJ7p'></q></dir></style></legend>

                <i id='LWJ7p'><tr id='LWJ7p'><dt id='LWJ7p'><q id='LWJ7p'><span id='LWJ7p'><b id='LWJ7p'><form id='LWJ7p'><ins id='LWJ7p'></ins><ul id='LWJ7p'></ul><sub id='LWJ7p'></sub></form><legend id='LWJ7p'></legend><bdo id='LWJ7p'><pre id='LWJ7p'><center id='LWJ7p'></center></pre></bdo></b><th id='LWJ7p'></th></span></q></dt></tr></i><div id='LWJ7p'><tfoot id='LWJ7p'></tfoot><dl id='LWJ7p'><fieldset id='LWJ7p'></fieldset></dl></div>

                    <tbody id='LWJ7p'></tbody>

                  <tfoot id='LWJ7p'></tfoot>

                1. 本文介绍了Laravel 5 计划不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 Laravel 版本是 5.0.28,我在 cloud9 上构建,并且在我的 cron 中添加了这个命令:

                  My laravel version is 5.0.28, I build on cloud9, and I added this command to my cron:

                  #!/bin/bash
                  PATH=/usr/bin
                  * * * * * php /home/ubuntu/workspace/app/artisan scheduled:run 1>> /dev/null 2>&1
                  

                  我在我的 Kernel.php 中添加了此代码.我参考了这个网站:https://laravel-news.com/2014/11/laravel-5-scheduler/

                  I added this code on my Kernel.php. I referenced this site: https://laravel-news.com/2014/11/laravel-5-scheduler/

                  <?php namespace AppConsole;
                  
                  use IlluminateConsoleSchedulingSchedule;
                  use IlluminateFoundationConsoleKernel as ConsoleKernel;
                  use AppHttpControllersApiController;
                  
                  class Kernel extends ConsoleKernel {
                  
                      protected $commands = [
                          'AppConsoleCommandsInspire',
                      ];
                  
                      protected function schedule(Schedule $schedule)
                      {
                          $schedule->call('ApiController@test_job')->hourly();
                      }
                  }
                  

                  我等了一会儿还是不行,所以我尝试使用命令php artisan schedule:run,我得到:没有准备好运行的预定命令.代码>

                  I waited and it still didn't work, so I tried to use the command php artisan schedule:run, and I got: No scheduled commands are ready to run.

                  我搜索并找到了这个答案:Laravel 5类不存在"使用调度器时

                  I searched and found this answer: Laravel 5 "Class does not exist" when using the scheduler

                  所以我修改了我的代码.另外,这段代码没有指定时间,所以我修改了我的 cron 来指定时间,但它仍然不起作用.我没有更多的想法.请帮忙.谢谢.

                  So I modified my code. Also, this code had no specified time, so I modified my cron to specify a time, but it still doesn't work. I have no more ideas. please help. Thanks.

                  代码

                  $schedule->call(join('@', [ApiController::class, 'test_job']));
                  

                  cron

                  0 0,3,6,9,12,15,18,21 * * * php /home/ubuntu/workspace/app/artisan schedule:run 1>> /dev/null 2>&1
                  30 1,4,7,10,13,16,19,22 * * * php /home/ubuntu/workspace/app/artisan schedule:run 1>> /dev/null 2>&1
                  

                  推荐答案

                  Laravel 调度程序 适用于命令,而不适用于控制器方法:

                  Laravel scheduler works with commands, not with controller methods:

                  1. 创建命令:

                  php artisan make:command PurchasePodcast
                  

                  1. 编辑命令:

                  namespace AppConsoleCommands;
                  
                  use IlluminateConsoleCommand;
                  
                  class PurchasePodcast extends Command
                  {
                      protected $name = 'purchase:podcast';
                  
                      public function fire()
                      {
                          // do stuff here
                      }
                  }
                  

                  1. ConsoleKernel.php添加命令:

                  protected $commands = [
                      'AppConsoleCommandsPurchasePodcast',
                  ];
                  

                  1. 在调度程序中使用命令:

                  $schedule->command('purchase:podcast')->hourly();
                  

                  这篇关于Laravel 5 计划不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)

                    <legend id='Um6zI'><style id='Um6zI'><dir id='Um6zI'><q id='Um6zI'></q></dir></style></legend>
                            <bdo id='Um6zI'></bdo><ul id='Um6zI'></ul>
                          • <i id='Um6zI'><tr id='Um6zI'><dt id='Um6zI'><q id='Um6zI'><span id='Um6zI'><b id='Um6zI'><form id='Um6zI'><ins id='Um6zI'></ins><ul id='Um6zI'></ul><sub id='Um6zI'></sub></form><legend id='Um6zI'></legend><bdo id='Um6zI'><pre id='Um6zI'><center id='Um6zI'></center></pre></bdo></b><th id='Um6zI'></th></span></q></dt></tr></i><div id='Um6zI'><tfoot id='Um6zI'></tfoot><dl id='Um6zI'><fieldset id='Um6zI'></fieldset></dl></div>

                            <small id='Um6zI'></small><noframes id='Um6zI'>

                              <tbody id='Um6zI'></tbody>
                            <tfoot id='Um6zI'></tfoot>