Question

I have tried with:

0 0 2 ? 1/1 SAT#1,SUN#1 *

but the result is wrong (only appears the sunday):

  1. Sunday, April 6, 2014 2:00 AM
  2. Sunday, May 4, 2014 2:00 AM
  3. Sunday, June 1, 2014 2:00 AM
  4. Sunday, July 6, 2014 2:00 AM
  5. Sunday, August 3, 2014 2:00 AM

also I have tried with:

0 0 2 1-7 * ? SAT,SUN and a lot of variants but all of them are invalid syntax.

The correct output should be:

  1. Saturday, April 5, 2014 2:00 AM
  2. Sunday, April 6, 2014 2:00 AM
  3. Saturday, May 3, 2014 2:00 AM
  4. Sunday, May 4, 2014 2:00 AM
  5. Sunday, June 1, 2014 2:00 AM
  6. Saturday, June 7, 2014 2:00 AM . . . .

I've been doing all the tests since http://www.cronmaker.com/ (nice page!) unsuccessfully. Regards

Was it helpful?

Solution 4

Cron Quartz definitely not allowed to do this in a single statement. I get error message: "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented."

OTHER TIPS

I've tried unsuccessfully too. In my opinion, Quartz Cron has some limitations.

By the way, can't you split your cron into two different schedules? For example:

0 0 2 ? 1/1 SAT#1 *
0 0 2 ? 1/1 SUN#1 *

0 and 7 stand for Sunday.

Hence, the numbers from 1 to 6 are fixed to Monday, ..., Saturday.

Graphically:

 +---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 |  |  |  +------- month (1 - 12)
 |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
 |  |  |  |  |
 *  *  *  *  *  command to be executed

0 0 1-7 * 0,6 * should work for you.

Cron

You have to split it to 2 cron expressions. From the documentation ( http://www.quartz-scheduler.org/api/2.2.0/org/quartz/CronExpression.html ) :

If the '#' character is used, there can only be one expression in the day-of-week field ("3#1,6#3" is not valid, since there are two expressions).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top