Laravel Scheduler Adds Support for Running Hourly Tasks on a Certain Minute

News

January 6th, 2017

laravel-scheduler.png

The Laravel Scheduler now includes a new method hourlyAt that will allow you to define the minute within the hour that it should run. This helpful in situations where you have a task that should run hourly but not at the top of the hour.

Using the same simple syntax as all the other methods and here is a quick example:

1$schedule->command('mytask')->hourlyAt(15);

This will set the command to run every hour on the 15th minute. Of course, you can still pair it with the other methods to get more fine-grained control:

1$schedule->command('mytask')
2 ->weekdays()
3 ->hourlyAt(15);

This feature is included starting at v5.3.29 and will allow you to use the familiar syntax instead of having to jump into using the cron method to define it.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.