Difference Between Cron trigger and Simple trigger in Quartz Scheduler

10,069

Solution 1

The differences between the two are merely how you wish to schedule the execution of your jobs. There are no other differences in terms of best practices or thread safety.

SimpleTrigger is useful for jobs that you want to execute exactly once at a specific time, optionally followed by repeated execution at a specific interval.

CronTrigger is much different in that it is for jobs that are inherently recurring on some calendar based schedule. So with CronTrigger you can schedule a job that runs every Sunday at 1AM.

The CronTrigger and SimpleTrigger tutorials contain some more detailed explanations and examples.

Solution 2

The difference comes when you wish interval based schedule.

Cron: if you put ‘0/15’ in the Minutes field, it means ‘every 15th minute of the hour, starting at minute zero’. If you used ‘3/20’ in the Minutes field, it would mean ‘every 20th minute of the hour, starting at minute three’ - or in other words it is the same as specifying ‘3,23,43’ in the Minutes field. Note the subtlety that “/35” does *not mean “every 35 minutes” - it mean “every 35th minute of the hour, starting at minute zero” - or in other words the same as specifying ‘0,35’.

Simple Trigger: if you want the trigger to fire at exactly 11:23:54 AM on January 13, 2015, or if you want it to fire at that time, and then fire five more times, every ten seconds.

Share:
10,069

Related videos on Youtube

practice2perfect
Author by

practice2perfect

Updated on October 02, 2022

Comments

  • practice2perfect
    practice2perfect over 1 year

    I am exploring on quartz scheduler,

    What are the differences between Cron trigger and Simple trigger except for how they are being defined. I dint find any other differences.

    like which is thread safe or which is said as best practice or anything like that.

    can someone explain what are the differences between them and at what scenarios we could use them

  • Tanu Garg
    Tanu Garg about 5 years
    can I generate a simple trigger for coming Monday?