Run Cronjob Every X Minutes
How can i run cronjob every X minutes for example 43 minutes?
is this right?
$schedule->command('command')->cron("*/43 * * * *")->withoutOverlapping();
Check this cron
43 * * * *
When you use */{int} you are saying "at every minute evenly divisible by {int}"
*/43 * * * * will run twice an hour. First at 00, then again at 43
Examples like */5 * * * * for every five minutes work out perfectly. Odd numbers, not so much.
You will have to get a little fancy to do what you want. Something like this (untested):
$time = Cache::get('my-command-next-time', now()->format('H:i'));
$schedule->command('command')->at($time)->after(function() {
Cache::put('my-command-next-time', now()->addMinutes(43)->format('H:i'), now()->addHour());
});
Please or to participate in this conversation.