Laravel "No scheduled commands are ready to run."

67,288

Solution 1

Did you try running command manually?

Run php artisan and see if your commands have registered.

If you have registered your commands you should see command:daily-reset and command:monthly-reset under the list of available artisan commands.

If you don't see them there go ahead and register your commands by adding it to commands property available in app/Console/Kernel.php.

protected $commands = [
    'App\Console\Commands\YourFirstCommand',
    'App\Console\Commands\YourSecondCommand'
];

Change crontab entry to

* * * * * php /home/privates/public_html/staging/current/artisan schedule:run

Solution 2

When you run

php artisan schedule:run

in the server, where your project is stored, you could see all of your commands running with output, looking like this:

"Running scheduled command: '/usr/local/bin/php' 'artisan' cache:update > '/dev/null' 2>&1 &"

but only if the current time is the exact one, for which the command is scheduled. Otherwise you are going to see this output:

"No scheduled commands are ready to run."

For example, if you schedule the command for every five minutes and run the command in 09:07 o'clock you will see that there are no scheduled commands, but if you run it in 09:10 you will see your command running.

In this way you can just schedule your command to run every 5 min just for debugging purposes:

$schedule->command('command:daily-reset')->everyFiveMinutes();

then observe if there is any error while running and eventually fix it. By me the problem was that I haven't installed GuzzleHttp (shame), so the fix was just running this in the terminal:

composer require guzzlehttp/guzzle

Solution 3

I realized that the problem for me was the below chained method:

->withoutOverlapping() 

Once I removed that method, my commands started running and being found by the daemon process.

I think there might be a bug with the method, but my project for now can take a bit overlapping so it's cool.

Solution 4

The Laravel scheduled commands are based in the timezone that you have configured in your app/config/app.php file (laravel 5.1):

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/

'timezone' => 'America/Bogota',

So if you create a command and register it to run as a scheduled task with:

$schedule->command('command:daily-reset')->daily();

it will run every day at 00:00 OF THE TIMEZONE SPECIFIED (in this case America/Bogota)

The same thing applies if you specify a time to run the task:

$schedule->command('command:daily-reset')->daily()->at('02:30');

This will run at 02:30 am in America/Bogota local time.

Solution 5

NB: This is not answer for this question, but a clue for anyone debugging with php artisan schedule:run manually. Hope it saves someone a few minutes of headache.

Check if the scheduled task can run immediately. You can use the exec method for that.

<?php
...

protected function schedule (Schedule $schedule) {
    $schedule -> exec("php artisan your:command");
}

The reason for this is that, you might be scheduling the task to run at a certain time and if that time isn't due yet, it will output: "No scheduled commands are ready to run."

Share:
67,288
Admin
Author by

Admin

Updated on February 19, 2022

Comments

  • Admin
    Admin about 2 years

    I've set up the following Laravel commands:

    protected function schedule(Schedule $schedule) {
            $schedule->command('command:daily-reset')->daily();
            $schedule->command('command:monthly-reset')->monthly();
    }
    

    Then, on my server, I've set up a cron job to run once per day (at 00:00).

    0 0 * * * php /home/privates/public_html/staging/current/artisan schedule:run
    

    My cron job is running successfully each night, but the logs simply say: "No scheduled commands are ready to run."

    What am I doing wrong? I would expect my daily command to run each night.

    Thanks!