1

this might sound an uncommon requirement, but I need to run a job on every 3 days, every hour on those particular days between 8 am to 10 am.

If I start today, it should run on below schedule:

  1. 2021-09-17 08:00:00 am
  2. 2021-09-17 09:00:00 am
  3. 2021-09-17 10:00:00 am
  4. 2021-09-20 08:00:00 am
  5. 2021-09-20 09:00:00 am
  6. 2021-09-20 10:00:00 am
  7. 2021-09-23 08:00:00 am
  8. 2021-09-23 09:00:00 am
  9. 2021-09-23 10:00:00 am

How can I schedule this using Quartz.net?

walen
  • 7,103
  • 2
  • 37
  • 58
nobody
  • 11
  • 2
  • Do you need it to run *exactly* every three days? Because I don’t think that’s possible with cron expressions. Day-based intervals are always aligned either to the beginning of a week or of a month. E.g. the cron expression `0 8-10 */3 * *` would mean [“At minute 0 past every hour from 8 through 10 on every 3rd day-of-month.”](https://crontab.guru/#0_8-10_*/3_*_*) So it will be irregular happening e.g. on September 28th and then again on October 3rd (because September has no 31th day). – poke Sep 17 '21 at 22:17
  • (Ehh, correction: It will actually happen on October 1st since it restarts then. A better example would be October 31st and then it happens again one day later on November 1st because the cycle reset.) – poke Sep 17 '21 at 22:27
  • Poke, I think this is what I needed. It ran on Sep 28 and then on Oct 1. So the expression is working correctly. Thanks a bunch! If you could post your comment as an answer, that would be great! – nobody Sep 17 '21 at 22:27
  • Uhh....You are correct, I started on oct 31, it ran on both oct 31 and Nov 1. how does the cycle work? Is there a way to fix this? – nobody Sep 17 '21 at 22:32
  • I think I understand the cycle now. Thanks for your help! – nobody Sep 17 '21 at 22:35
  • As I said, I don’t think there is with cron expressions since those are either month-based (every xth days of a month) or week-based (every xth days of a week). You would need to look for a different scheduler system then. You might be able to do this with a [custom trigger](https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/jobs-and-triggers.html#jobs-and-triggers). – poke Sep 17 '21 at 22:36

0 Answers0