6

I have made a scheduler. When I call it with php artisan userRanking it works.

This is the code in Kernel.php:

protected $commands = [
    \App\Console\Commands\UserRanking::class,
];

protected function schedule(Schedule $schedule)
{
    $schedule->command('userRanking')
             ->everyMinute();
}

How do I dispatch it so that it runs automatically?

1
  • Can you please tell me how did you add * * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1 Commented Feb 2, 2016 at 13:47

1 Answer 1

19

You have to set up a single cron job that calls the schedule runner every minute:

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

Read Laravel's Scheduler docs for more info.

Sign up to request clarification or add additional context in comments.

8 Comments

how to set this cron job and where exactly ?
@user2099451 - there are tons of tutorials on the web for that. Here's one.
I dont want to start a new topic but Im new and nothing makes sense: I see "everyMinute()", so why do I need to run a cron job to execute a function that does things every minute?
@Sylar task won't run automatically, for that you need to set up cron which will execute your task every minute automatically
@Sylar to be clear, the cron starts "laravel" scheduler every minute. That scheduler will check upon each run, every minute, and see what schedules you have created and needs to be run that minute. Without the system cron/scheduler running laravel every minute, there would be nothing to start your scheduled command. The laravel scheduler does not start and stay running; it starts, checks, and closes.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.