tags:

views:

197

answers:

5

guys,

please suggest me best algo for the below situation:

I have some taks which are to be scheduled by users anytime, the tasks may have recurring options(periodically/weekly/monthly...).I have to run these tasks at the scheduled time.

  1. Run only once after a specified start date
  2. Run periodically for every 1 hour after a specified date
  3. Run every week monday and tuesday for every i hr after a specified date
  4. Run monthly at a particular date after a specified date.

Its better if you give the code snippet ...

+1  A: 

I suggest that you look at Quartz if you want a Java solution. That link points to the Quartz features page, which looks like it could be a good fit to your requirements. A stack of examples may be found here.

Stephen C
+1  A: 

Quartz is a nice, open, extendable, Java based library.

mikek
+2  A: 

The Hudson integration server does exactly the same (in Java). It even implements the cron syntax allowing complex schedules. And it's open source.

Andreas_D
+4  A: 

Use a scheduler like Quartz or cron4j (pretty decent library and more lightweight than Quartz).

Pascal Thivent
+1  A: 

If it's not mandatory that you use Java for this, you should just use cron. This is what cron is for.

uckelman