Ad
Task Scheduling On Custom Day Laravel
I want do this job oly on this days can I use at() with when() ????
$schedule->command('mycommand')->when(function () {
$day = Carbon::today()->day;
if($day == 3 || $day == 5 || $day == 7 || $day == 22) {
return true;
} else {
return false;
}
})->at('17:00');
Ad
Answer
You can use this way :
$schedule->command('mycommand')->monthlyOn(3, '17:00');
$schedule->command('mycommand')->monthlyOn(5, '17:00');
$schedule->command('mycommand')->monthlyOn(7, '17:00');
$schedule->command('mycommand')->monthlyOn(22, '17:00');
Or, simpler way, using cron :
$schedule->command('mycommand')->cron('0 17 3,5,7,22 * *');
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad