Issue
I'm trying to schedule a task to run on the “first Wednesday of the month at 9 AM” by using a cron expression.
The best I've got so far is 0 9 * * 3
which translates to “at 09:00 on Wednesday.” But that's every Wednesday, unfortunately.
Is it even possible to express that occurence in a cron expression?
Solution
You can use this syntax
0 9 1W * *
1W
will specify the first Wednesday of the month.
The answer below does not appear to work (at least according to some online tools)
You can take advantage of the ability to specify multiple days in the 3rd parameter, like this:
0 9 1-7 * 3
Trying the expression in https://crontab.cronhub.io/, this is how the above gets described:
At 09:00 AM, between day 1 and 7 of the month, and on Wednesday
You can be sure that one and only one of the first 7 days of the month will be Wednesday, and is also the first Wednesday of the month.
Answered By - KernelDeimos Answer Checked By - Marie Seifert (WPSolving Admin)