Mr Robot
Mr Robot

Reputation: 897

Laravel CRON job not working in aws

I have deployed laravel 5.4 app in AWS Ubuntu 16.04 apache2, i have created task scheduler for sending emails dailyAt('10:00').

When i run the artisan command php artisan email:reminder manually every thing works fine.

But when i run php artisan schedule:run i am getting No scheduled commands are ready to run.

I have also ran * * * * * php /var/www/html/app/artisan schedule:run >> /dev/null 2>&1 referring to documentation.

This is Kernal.php

class Kernel extends ConsoleKernel
{
    protected $commands = [
        \App\Console\Commands\EmailReminder::class,
    ];

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('email:reminder --force')->dailyAt('10:00');
    }

    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

Upvotes: 0

Views: 1816

Answers (2)

Bira
Bira

Reputation: 5506

In AWS ECS we can use this without adding cron in to the container

https://github.com/spatie/laravel-cronless-schedule

php artisan schedule:run-cronless

Upvotes: 1

Sérgio Reis
Sérgio Reis

Reputation: 2523

Your schedule will only work if you call it at 10:00,

add this cronjob

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

Laravel will call this function everyminute, and once it is 10:00 it will call the function accordingly. Check https://laravel.com/docs/5.5/scheduling#introduction , search for 'Starting The Scheduler'

Upvotes: 1

Related Questions