1

I want to write a cron expression which does the following -

Starting every last Sunday of September at 9:00 am and repeating every 3 weeks till end of the year.

I have come up with

0 0 9 ? 9 6L

How can i make this repeat every two weeks till end of the year.

Thanks in advance

Coder
  • 3,090
  • 8
  • 49
  • 85

1 Answers1

1

There is no way to do that using cron. I suggest you to run your script every day using

0 0 9 * 9-12 ? 2013

And inside your script check if it is a right time to execute. If it is not then exit immediately.

Aleks-Daniel Jakimenko-A.
  • 10,335
  • 3
  • 41
  • 39
  • Can you please explain what does your cron expression do? – Coder Aug 21 '13 at 02:54
  • If I want to repeat it every year then is this correct - 0 0 9 * 9-12 ? * – Coder Aug 21 '13 at 02:56
  • @OpenSourceRulzz it runs every day at 9:00 only in September, October, November and December. Yes, if you want it to happen every year, then it is correct. But note that it wont work in other months like January or May. The point here is that cron does not allow you to do complex things. If you need that complicated logic, then you have to run your script more frequently than needed and use checks in your script so it terminates if it is not the right time. – Aleks-Daniel Jakimenko-A. Aug 21 '13 at 06:02