Eric Barnes has a longer write up on this, so I’ll just keep it short:

5.0 is introducing a pretty incredible cron-style scheduler (similar to Indatus’ Dispatcher) built into the core. Just point a cron job that’s scheduled once a minute at artisan schedule:run and you’re good to go.

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

For example, you can now bind the following to clear your auth reminders daily:

    ->emailOutputTo('[email protected]');

You can use commmand() to call artisan commands, call to call methods or functions, or terminal() to run command line scripts:

$schedule->call('[email protected]')->twiceDaily();
$schedule->call(function() {
    // Do stuff
$schedule->terminal('cp oldThing newThing')->dailyAt('8:00');

You can also use a callback to decide when something will or won’t run, using when() or skip():

    ->call('[email protected]r')
    ->skip(function(TypeHintedDeciderClass $decider)
        return $decider->isHoliday();

This is just a quick introduction, though; check out Eric’s post for a fuller rundown: Laravel 5 Scheduler on Laravel-News

Source link


Please enter your comment!
Please enter your name here