cron-expression
cron-expression copied to clipboard
Settings the day of week and day of month.
If both fields are restricted (for day of month and day of week) a cron should match for either case, as per the cron man:
Note: The day of a command's execution can be specified by two fields -- day of month, and day of week. If both fields are restricted (ie, are not *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
However, in a test with the following expression:
0 16 4 * fri *
The expected behavior is every Friday OR every month on the 4th.
However, when running this, it matches if it is a Friday AND it is the forth: here is sample output:
Next: Fri, 04 Nov 2016 16:00:00 +0000 Last: Fri, 04 Mar 2016 16:00:00 +0000
Great library otherwise.
Please dont change the week + day-of-month into "OR" combination. "AND" is very useful in below practical scenario:
"First sunday of month" 0 0 1-7 * 7
This is not possible in the "OR" condition.
you must use two cron expression for this
0 16 4 * * * 0 16 1-7 * fri *