Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz scheduler vs setting up cron

Was planning to move from setting up cron jobs to Quartz scheduler. What are the pros/cons of using Quartz rather than setting up cron ?

Got this Time triggered job Cron or Quartz? link. Any other pointers ?

like image 300
Mohit Verma Avatar asked Feb 28 '12 07:02

Mohit Verma


People also ask

What is difference between scheduler and cron job?

Cron allows you to create your own chains manually. Scheduler allows you to place resource control (CPU limits, undo tablespace limits, etc) against your job. It allows you to define classes with priorities and assign jobs to those classes.

Does Quartz use cron?

The component uses either a CronTrigger or a SimpleTrigger . If no cron expression is provided, the component uses a simple trigger. If no groupName is provided, the quartz component uses the Camel group name.

Why should we use Quartz scheduler?

Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do.

What does cron 0 * * * * * mean?

*/5 * * * * Execute a cron job every 5 minutes. 0 * * * * Execute a cron job every hour.


1 Answers

I have used and like quartz. Here are some advantages of quartz

  1. If you use an OS based cron the jvm would go up and down and any state would be lost.
  2. it is portable (can run on Win OS where no cron available)
  3. You can schedule multiple threads within quartz
  4. We run our scheduler in tomcat and so we can manage and see the state of the app via admin web pages. In our app we use jamon to monitor the state of our processes. It can answer such things as... Which processes are currently running? When did they last run? How long did they take? etc. cron would not allow this.
  5. Your code would be more portable. Scheduling is done differently in different OS's.

Probably quartz should be seen more as a replacement for launching new threads than as a replacement of cron.

partially stolen from here

like image 183
aviad Avatar answered Sep 30 '22 17:09

aviad