3 ms·
> "Tell me a cron expression to run command on each third Monday of a month and explain it" ChatGPT responds: > 0 0 0 ? * MON#3 * Regarding MON#3, it explain
by cuu508 3y ago
> "Tell me a cron expression to run command on each third Monday of a month and explain it"
ChatGPT responds:
> 0 0 0 ? * MON#3 *
Regarding MON#3, it explains: "Day of the week (MON#3): This is the crucial part of the expression. We use MON to specify that we want the command to run on a Monday. Then we append #3 to indicate that we want the third occurrence of Monday. This ensures that the command will run on the third Monday of the month."
It does not mention though, even with the smallest hint, that standard cron does not support this syntax. Or a 7-field syntax.
(By "standard cron" I mean Vixie cron derivatives like the one that ships with Debian)
The correct answer in this case would have been: "This is not possible with standard cron syntax alone. You can either use a different cron implementation that supports MON#3, or schedule for every Monday, but then in your script check if it's the third Monday."