I need to run some data update functions each hours 15 minutes. For example:
- 12:15
- 13:15
- 14:15
- 15:15
How to create schedule for it? I tried something like $schedule->command('stats:refresh')->hourly()->at(':12');
but didn’t work.
I need to run some data update functions each hours 15 minutes. For example:
How to create schedule for it? I tried something like $schedule->command('stats:refresh')->hourly()->at(':12');
but didn’t work.
Try something like $schedule->command('stats:refresh')->cron('15 0-23 * * * *')
Cron uses 5 asterisks as arguments. I've made a pull request, because I thought there is a mistake in Laravel documentation: https://github.com/laravel/docs/pull/2166
But here's answer from main Laravel developer:
There is an optional 6th "year" argument available: http://www.nncron.ru/help/EN/working/cron-format.htm
If you click the last link, you'll see description of which one of the six asterisks.
You can use
$schedule->command('command')->cron('* * * * *')
Every star from left to right refers to
- minute (0-59)
- hour (0-23)
- day of month (1-31)
- month (1-12)
- day of the week (0 is Sunday, 6 is Saturday)
please take look at : http://maxoffsky.com/code-blog/practical-laravel-using-cron-jobs-in-laravel/
You can do like this.
...
$schedule->command('your:command')->everyFiveMinutes();
...
Hope it help you.
@Alexey it should be
$schedule->command('stats:refresh')->cron('15 0-23 * * *')
instead. If you add 15 0-23 to your asterisks it makes 6 instead of 5.