views:

95

answers:

3

Hi,

Does the following cron expression mean "execute every other Sunday?" (I'm trying to use it with the Spring Quartz scheduler)

0 0 3 ? * 2/1 *"

Thanks

Nick

A: 

No, I don't think so. I think "2/1" means "Tuesday through Sunday." I'm not sure that it's possible to express "Every other Sunday", because there'd have to be a "week of month" field or something like that.

Pointy
+2  A: 

The expression you are asking about fires at 3 am Monday to Saturday. From the Quartz Javadoc you could try using the two expressions 0 0 3 ? * 1#1 * and 0 0 3 ? * 1#3 * to execute on the 1st and 3rd Sundays of the month. The D#N syntax lets you pick the Nth day D of the month.

laz
Out of curiosity, how is it Monday? Isn't "2" Tuesday? Maybe it's locale-dependent ...
Pointy
Check out that Quartz Javadoc I linked to. Quartz goes from 1-7 (Sun - Sat) and Vixie cron goes from 0-7 (Sun - Sun). It seems that is one of the differences between Quartz cron and Vixie cron.
laz
That's great, thanks
A: 

would "* * * * * SUN/2" work?

glowcoder
The would fire every 2 days starting on Sunday. So Sunday, Tuesday, Thursday, Saturday, repeat.
laz