Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time triggered job Cron or Quartz?

I already asked a separate question on how to create time triggered event in Java. I was introduced to Quartz. At the same time, I also google it online, and people are saying cron 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.

like image 802
Lily Avatar asked Jun 22 '09 21:06

Lily


1 Answers

  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).
like image 129
Grzegorz Oledzki Avatar answered Oct 11 '22 05:10

Grzegorz Oledzki