Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Greg Kaleka
Greg Kaleka
39,021 Points

Laravel issue: artisan schedule:run not working

In my Laravel app, I have a task scheduled to run an artisan command, and for some reason schedule:run is not working properly.

Here is my schedule() function:

Kernel.php
<?php
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('mydomain:sendalerts 100')
                 ->everyMinute();

        // $schedule->call(function() {
        //     Mail::raw('Testing from mydomain', function($message)
        //     {
        //         $message->to('me@gmail.com')->from('alerts@mydomain.com');
        //     });
        // })->everyMinute();
    }

In the console, calling php artisan mydomain:sendalerts 100 works. Calling php artisan schedule:run does not work. However, when the code below is un-commented, calling php artisan schedule:run does send the test email. So schedule:run is working. The command is working. But schedule:run does not successfully call the command.

When I call php artisan schedule:run, here is the console output:

root@mydomain:/var/www/laravel/current# php artisan schedule:run
Running scheduled command: /usr/bin/php5 "artisan" mydomain:sendalerts 100 > /dev/null 2>&1 &

What am I doing wrong??