Framework: Php artisan schedule:run not working

Created on 5 Jan 2017  路  8Comments  路  Source: laravel/framework

  • Laravel Version: 5.2.45
  • PHP Version: 5.6.25
  • Database Driver & Version: Mysql Ver 14.14 Distrib 5.6.31, for osx10.6 (i386) using EditLine wrapper

I am trying Laravel schedule command to run some background process for sending mails and fetching emails. When I run these commands individually using artisan they all run, but when I try to run shcedule:run command to run these commands it shows "No scheduled commands are ready to run."

I've tried to look for an answer but nothing worked. So I tried to rectify the problem by running simple command and check the output. Below is my kernal.php

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
//use App\Model\MailJob\Condition;

class Kernel extends ConsoleKernel {

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\Inspire::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     *
     * @return void
     */
    protected function schedule(Schedule $schedule) {
        $schedule->command('inspire')->everyMinute();
        dd($schedule);
    }


}

when I run schedule:run it shows this output.

BhanuSlthiasMBP:Faveo-Helpdesk-Pro-bhanu-fork vijaysebastian$ php artisan schedule:run
Illuminate\Console\Scheduling\Schedule {#54
#events: array:1 [
0 => Illuminate\Console\Scheduling\Event {#1680
+command: "'/Applications/AMPPS/php-5.5/bin/php' 'artisan' inspire"
+expression: "* * * * * *"
+timezone: null
+user: null
+environments: []
+evenInMaintenanceMode: false
+withoutOverlapping: false
+runInBackground: false
#filters: []
#rejects: []
+output: "/dev/null"
#shouldAppendOutput: false
#beforeCallbacks: []
#afterCallbacks: []
+description: null
}
]
}

But when I remove dd() in schedule() function the output is

BhanuSlthiasMBP:Faveo-Helpdesk-Pro-bhanu-fork vijaysebastian$ php artisan schedule:run
No scheduled commands are ready to run.

Please help me, I am using laravel 5.2

Most helpful comment

Your Laravel version is outdated, and you are using PHP 5.5 according to that path.

Is you application down for maintenance? Can you run php artisan up to disable maintenance mode and try again?

All 8 comments

Your Laravel version is outdated, and you are using PHP 5.5 according to that path.

Is you application down for maintenance? Can you run php artisan up to disable maintenance mode and try again?

@sisve Firstly thanks for your quick response; I have run php artisan up but still it is not working.

My Php version

Bhanu-Slathias-MacBook-Pro:Faveo-Helpdesk-Pro-bhanu-fork vijaysebastian$ php --version
PHP 5.6.25 (cli) (built: Aug 27 2016 13:55:31) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

My Laravel version

Bhanu-Slathias-MacBook-Pro:Faveo-Helpdesk-Pro-bhanu-fork vijaysebastian$ php artisan --version
Laravel Framework version 5.2.45

Laravel 5.2 supports task scheduling, so this feature should work,

1) Your paste indicates that you use php from /Applications/AMPPS/php-5.5/bin/php, not the system-wide installed php.
2) Support for Laravel 5.2 was dropped when Laravel 5.3 was released.

Next step in debugging would probably be to edit Event::isDue and see what it returns.

@sisve you are correct, I have changed my php version; But no change

Illuminate\Console\Scheduling\Schedule {#54
  #events: array:1 [
    0 => Illuminate\Console\Scheduling\Event {#1083
      +command: "'/Applications/AMPPS/php-5.6/bin/php' 'artisan' queue:listen"
      +expression: "* * * * * *"
      +timezone: null
      +user: null
      +environments: []
      +evenInMaintenanceMode: false
      +withoutOverlapping: false
      +runInBackground: false
      #filters: []
      #rejects: []
      +output: "/dev/null"
      #shouldAppendOutput: false
      #beforeCallbacks: []
      #afterCallbacks: []
      +description: null
    }
  ]
}

@sisve interesting thing is, If i remove .env file, it is executing ! WHY ?

What if you have an empty .env file? Could you remove one setting at a time from your .env file to see when it starts to work? The goal is to find out which specific configuration setting is required to reproduce the issue.

Sounds like this is a task for the forums until there's something that can be presented clearly in a new issue.

It seems I have same problem, too.

In my case: I use AWS elasticbeanstalk to deploy, I do not use .env file in Environment but I use Elastic Beanstalk Environment Properties to set Env variable via $_SERVER.

I modified my database.php a little bit for load DB_HOST, DB_PORT, etc from $_SERVER instead of env file
=> It works

But when I tried to implement an scheduler, It seems use .env file to get DB_HOST, DB_PORT, etc, and it failed to run scheduler.

Do you have any suggestion for me?

Was this page helpful?
0 / 5 - 0 ratings