Core components of my heart (pluggable AOP) ~ Dispatch Component Quartz.net-Task Manager development (Crontrigger Power)

Source: Internet
Author: User

Back to Catalog

The last time we developed a quartz management tool, mainly using simple trigger as a trigger, if you think it is too simplistic to achieve our function, we can introduce the concept of cron, which is called the time expression, it can be flexible to set a variety of strategies, Let's take a look at some basic knowledge of cron expression first.

Format: [seconds] [min] [hour] [day] [month] [week] [year]
The serial number indicates whether the allowed wildcard characters are required to fill in the allowable values
1 seconds is 0-59,-*/
2 points is 0-59,-*/
3 hours is 0-23,-*/
4th is 1-31,-*? /L W
May is 1-12 or JAN-DEC,-*/
6 weeks is 1-7 or SUN-SAT,-*? L
7 years no empty or 1970-2099,-*/

A wildcard Description:

1. The backslash (/) character represents the increment value. For example, in the seconds field, "5/15" represents the beginning of the 5th second, once every 15 seconds.

2. The asterisk (*) character is a wildcard character, which means that the field can accept any possible value (for example, setting "*" on a divided field, indicating that every minute will be triggered).

3. Question mark (?) indicates that the field does not contain a specific value. So, if you specify a date within a month, you can insert "?" in the Date field within the month, indicating that the date value in the week is irrelevant. The letter L character is the last abbreviation. Placed in the Month Date field, indicates that the schedule is scheduled to be executed on the last day of the month. In the week Date field, if "L" exists alone, it is equal to "7", otherwise it represents the last instance of the week date within the month. So "0L" means that it is scheduled to be executed on the last Sunday of the month.

4.-Indicates the interval, such as setting "10-12" on the hour, indicating that the 10,11,12 point will be triggered.

5. A comma (,) indicates that multiple values are specified, such as setting "Mon,wed,fri" on the week field to indicate Monday, Wednesday, and Friday triggers

6. The pound sign (#) character specifies a specific weekday instance for a given month. Put "mon#2" in the week Date field, indicating that the task is scheduled for the second Monday of the month.

7. L indicates the last meaning. On the day field setting, the last day of the month (according to the current month, if February is also based on whether it is run year [leap]), the week field represents Saturday, which is equivalent to "7" or "SAT". If you precede the "L" with a number, it represents the last of the data. For example, setting the format "6L" On the week field means "last Friday of the month".
8. W represents the most recent working day from the specified date (Monday to Friday). For example, set "15W" on the day field, which indicates the most recent day of the month from 15th. If the number 15th is exactly Saturday, then find the most recent Friday (14th) trigger, if 15th is a week, then find the nearest next Monday (16th) trigger. If the number 15th is on the weekday (Monday to Friday), it will be triggered on that day. If the specified format is "1W", it represents the next most recent weekday trigger of 1th per month. If the number 1th is Saturday, it will be triggered by the number 3rd in Monday. (Note that the "W" can only be set to a specific number before the interval "-") is not allowed.

Note: ' L ' and ' W ' can be used in a combination. If "LW" is set on the day field, it is triggered on the last business day of the month.

Common examples

0 * * *?--------------run 10 minutes per hour

0 0/32 8,12 * *? ----------performed once a day 8:32,12:32

0 0/2 * * *?--------------executed every 2 minutes

0 0 * *?---------------triggered at 12:00 noon every day

0 15 10? * *---------------triggered 10:15 daily

0 * *?---------------trigger every day 10:15

0 15 10 * *? *---------------triggered daily 10:15

0 15 10 * *? 2005---------------triggered 10:15 every day in 2005 years

0 * * *?---------------triggered every minute from 2:00 to 2:59 every day

0 0/5 * *?---------------triggered every 5 minutes from 2:00 to 2:59 every day

0 0/5 14,18 * *?---------------triggered every 5 minutes from 2:00 to 2:59 and 6:00 to 6:59 daily

0 0-5 * *?---------------triggered every minute from 2:00 to 2:05

0 10,44 14? 3 WED---------------triggered every March Wednesday at 2:00 and 2:44

0 15 10? * Mon-fri---------------from Monday to Friday daily 10:15

0 *?---------------triggered at 10:15 every 15 days per month

0 L *?---------------triggered 10:15 on the last day of each month

0 15 10? * 6L---------------triggered at 10:15 of the last Friday of each month

0 15 10? * 6L 2002-2005---------------in 2002, 2003, 2004 and 2005 last Friday of the month of the 10:15 trigger

0 15 10? * 6#3---------------triggered at 10:15 on the third Friday of each month

0 0 1/5 *?---------------triggered every 5 days from the first day of each month at 12:00 noon

0 Each?---------------triggered at 11:11 each November 11.

Finally, design the model.

   /// <summary>    ///Cron Trigger Object/// </summary>     Public classQuartzcronmodel {[DisplayName ("Task Name")] [Required] Public stringJobName {Get;Set; } [DisplayName ("workgroup name")] [Required] Public stringJobgroup {Get;Set; } [DisplayName ("Task Assembly")] [Required] Public stringDll {Get;Set; } [DisplayName ("Trigger Name")] [Required] Public stringtriggername {Get;Set; } [DisplayName ("triggers workgroup")] [Required] Public stringTriggergroup {Get;Set; } [DisplayName ("cron-expression")] [Required] Public stringcronexpression {Get;Set; } [DisplayName ("Running State")] [ReadOnly (true)]         PublicTriggerstate Runstatus {Get;Set; }

Post-run effects

Back to Catalog

Core components of my heart (pluggable AOP) ~ Dispatch Component Quartz.net-Task Manager development (Crontrigger Power)

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.