Laravel cron error does not execute

Asked

Viewed 185 times

1

I have a cron that should be running every day in an hour.

$Schedule->command('inspire')->dailyAt('15:00');

but he is not being executed

Code

<?php

namespace App\Units;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel;
use App\Console\Commands\EnvioEmailBlCron;

class ConsoleKernel extends Kernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [

        \App\Console\Commands\EnvioEmailBICron::class 
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     */
    protected function schedule(Schedule $schedule)
    {

        //configuração do cron
        $schedule->command('inspire')->dailyAt('15:00'); 
        $schedule->command('envioemailbicron:cron')->daily(); // email diários
    }

    /**
     * Register the Closure based commands for the application.
     */
    protected function commands()
    {
    }
}

Command running on cmd:

php Artisan envioemailbicron:cron

  • Not this command. The command to execute is php artisan schedule:run, this command must execute at configured time the commands that are listed in the function schedule

  • receive this message: No scheduled.

  • Oxe, because there is not. See that one is configured to run only at 15:00, and another every day at midnight.

  • as I register my command ?

  • Your command is already registered. You have scheduled two commands to be executed, what you need to do is put the command php artisan schedule:run to be rotated every minute in the cron.

  • how do I do that ?

  • https://stackoverflow.com/questions/5398014/using-crontab-to-execute-script-every-minute-and-another-every-24-hours

  • insert the comondo here : protected $Commands = []

  • error still persists !

  • What error persists? No error.

  • No scheduled Commands are ready to run.

  • I told you. There are no commands to execute now. You have determined that the command inspire be executed every day at 3:00 PM, NOW IT’S NOT 3:00 PM, and the other command has ordered that you be executed every day at MIDNIGHT, now it’s not midnight either.

  • I changed the time to 15:20, 15:30 and 16:00, 16:20, 16:30 and nothing was executed

  • continues displaying the message: No scheduled Commands are ready to run

Show 9 more comments

2 answers

1


Try this

$schedule->command('envioemailbicron:cron')->everyMinute();
Show 2 more comments

0

To run the Inspire command you need to add it to the kernel..

protected $commands = [

    \App\Console\Commands\EnvioEmailBICron::class,
    \App\Console\Commands\Inspire::class,


];

If your Inspire command is in the default path, just add it to your protected

  • after the command is executed in the terminal: it loops ??

  • should execute command after executing Crom (24h/1h/minute) ??

  • the command I passed before executes every minute

  • Dude, take a look at the handbook of the Laravel, it’s pretty detailed, it’s not hard to understand there

  • ...eternally ??

Browser other questions tagged

You are not signed in. Login or sign up in order to post.