3

I'm using laravel 4 and i need to execute script every Monday, Tuesday, Wednesday, Thursday and Friday at 16:00h. Right now im using method dailyAt(16:00), but i dont want to script execute at Suturday and Sunday. My command looks like this in Kernel.php:

$schedule->command("script")->dailyAt("16:00")->sendOutputTo("NUL");
fr33jumper
  • 103
  • 3
  • 13
  • 1
    Simple way is checking day in week and execute script for weekdays only https://stackoverflow.com/questions/4802335/checking-if-date-is-weekend-php – Tuan Duong Mar 05 '18 at 08:08
  • I left script to run every day at 16:00 and in code i wrote to check if is Sut or Sun so script wont be executed. – fr33jumper Mar 05 '18 at 10:20

2 Answers2

2
$schedule->command("script")->weekdays("16:00")->sendOutputTo("NUL");

This one is from Monday to Friday. Take a look at laravel documentation for task scheduling for more Info!!!

pr1nc3
  • 8,108
  • 3
  • 23
  • 36
2

The correct way to limit tasks to weekdays is to chain weekdays() method. Like:

$schedule->command("script")->weekdays()->dailyAt("16:00")->sendOutputTo("NUL");
Malik Ahmed Khan Awan
  • 1,920
  • 2
  • 15
  • 15