CF Adminstrator scheduled task to run at the last day of the year using CRON TIME expression
Cron expression to schedule the task which will run at 11:45 pm at the end of the year
Cron expression to schedule the task which will run at 11:45 pm at the end of the year
0 45 23 31 12 ?
This is what you need for it to work in the CF sched task mechanism. You may have found instead resources online suggesting it could be just this:
45 23 31 12 *
...such as at https://crontab.guru/#45_23_31_12_*. But if you use that for a CF task, you'd get:
CronExpression '45 23 31 12 *' is invalid.
The problem is in how the underlying Quartz open source library (which CF uses for scehduled tasks) expects its cron values to be specified.
Traditional crontab format is:
minute, hour, day of month, month, day of week
The quartz cron pattern instead adds to that support for seconds (first field, required) and year (last field, optional):
second, minute, hour, day of month, month, day of week, year
Also, while the * for day of week (last value in my proposed expression) should work (according to the Quartz docs), I found that it did not, but the ? did. Technically, the ? should only be needed when some following field would be required but you wanted to imply "any" for the field with the "?". Logically, either should have worked. Oh well.
FWIW, CF2021 still uses only quartz 2.2.1, so I linked to the docs 2.2.2, which is close enough:
Also, here is a nifty online tool I found to help generate (or understand) a Quartz cron string. (I was reminded of it it after posting my answer, and I want to offer it here to help future readers.) It, too, shows using that ? in the 6th field...though it then shows using also the * for the 7th. As I noted above that's not needed, but I'll note here it does work (to switch the last "?" with "? *").
Let us know if that gets you going. I tested it (using a date and time of today) and it did work for me, in CF2021.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.