views:

891

answers:

2

I already asked a separate question on how to create time triggered event in Java: http://stackoverflow.com/questions/1029164/large-scale-time-triggered-event-handling. I was introduced of Quartz. At the same time, I also google it online, and ppl are saying Cron command in Unix is a neat solution.

Which one is better? What's the cons and pros?

Some specification of the system: * Unix OS * program written in Java * I have a task queue with 1000+ entries, for each timestamp, up to 500 tasks might be triggered.

Thanks so much.

Lily

+5  A: 
  1. Using cron seems to add another entry point into your application, while Quartz would integrate into it. So you would be forced to deal with some inter-process communication if you wanted to pass some information to/from the process invoked from cron. In Quartz you simply (hehe) run multiple threads.
  2. cron is platform dependent, Quartz is not.
  3. Quartz may allow you to reliably make sure a task is run at the given time or some time after if the server was down for some time. Pure cron wouldn't do it for you (unless you handle it manually).
  4. Quartz has a more flexible language of expressing occurences (when the tasks should be fired).
  5. Consider the memory footprint. If your single tasks share nothing or little, then it might be better to run them from the operating system as a separate process. If they share a lot of information, it's better to have them as threads within one process.
  6. Not quite sure how you could handle the clustering in the cron approach. Quartz might be used with Terracotta following the scaling out pattern (I haven't tried it, but I believe it's doable).
Grzegorz Oledzki
wow! I really appreciate your extensive comparison! That's exactly what I have been looking for. THANKS so much!!!!
Lily
Quartz has its own clustering functionality, you don't need to add a distribution layer to it. It allows you to say "run this job on the cluster somewhere".
skaffman
this functionality is pretty impressive, cauz' I will be dealing with cluster later. ^_^ Thanks skaffman~
Lily
A: 

The plus for cron is that any sysadmin knows how to use it and it's documented in many places. If cron will do the job then it would really be the preferred solution.

Jon Strayer