Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Laravel schedule job on Monday and Wednesday

How to schedule the job which needs to be run on custom days in Laravel.

eg) Monday and Wednesday only.

Wondering will it work or not?

 $schedule->command('report:sendEmail')->timezone('America/New_York')->weekdays()->mondays()->wednesdays()->dailyAt('21:30'); 
like image 929
Albert Avatar asked Oct 19 '25 17:10

Albert


1 Answers

What about this one.

 $schedule->command('report:sendEmail')->timezone('America/New_York')->cron('30 21 * * 1,3');

Above is the command to run your job at every Monday and Wednesday at 9:30 PM.

Below is the format of cron job

# Use the hash sign to prefix a comment
# +---------------- minute (0 - 59)
# |  +------------- hour (0 - 23)
# |  |  +---------- day of month (1 - 31)
# |  |  |  +------- month (1 - 12)
# |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)
# |  |  |  |  |
# *  *  *  *  *  command to be executed
#--------------------------------------------------------------------------

I suggest you to use http://corntab.com/ for creating cron rules in future.:)

like image 189
Sathishkumar Rakkiyasamy Avatar answered Oct 22 '25 08:10

Sathishkumar Rakkiyasamy