Quartz_2 _ CronTrigger)

Source: Internet
Author: User

The second trigger in the task scheduler to be introduced is CronTrigger. Compared with SimpleTrigger, CronTrigger is more flexible and more practical for complex business needs. Before using CronTrigger, you must first introduce the Cron expression. Here, the content of Cron expressions is introduced on the Internet. The theoretical content is roughly the same.

The content of the Cron expression is as follows:

The special symbols in the expression indicate:

"?" Character: indicates an uncertain value, for example, 0 0 0 **?)

"," Character: specifies several values

-Character: Specifies the range of a value.

"/" Character: Specifies the increase range of a value. N/m indicates that m is increased each time starting from n.

"L" character: Used in the day to represent the last day of the month, used in the week to represent the last day of the month X

"W" character: Specifies the business day closest to the given date (Monday to Friday)

"#" Character: indicates the week X of the month. 5 #2 indicates the first Thursday of the month

AM on every Monday, Thursday, and Thursday
AM on the 10th of every month
AM on the last day of each month
AM on the last Friday of every month
At AM on the last Friday of 2014,201, 2016, and 2017
AM on the third Friday of every month
Every five days from the first day of every month (noon)
Every November 11 AM
And every Wednesday in March

 

QuartzCronTiggerJob execute (JobExecutionContext jobContext) "This Is A cronTrigger test class"

(2) Task Scheduler

                   Scheduler scheduler =            JobDetail jobDetail ="cronTriggerDetail", "cronTriggerDetailGrounp"            JobDataMap jobDataMap ="name", "cronTriggerMap""group", "cronTriggerGrounp"            CronTrigger cronTrigger =                                        newTrigger().                                        withIdentity("cronTrigger", "cronTrigger""0 48 14 * * ?"                                        build();            

The above is the simple use of CronTrigger of Version 2.0. You can schedule tasks based on specific services.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.