Spring timed Task Configuration error

Source: Internet
Author: User

使用spring定时任务出现:Caused by: java.lang.IllegalArgumentException: Range exceeds maximum (60): 10000,原来是cron表达式第一个值不能大于60,60也不行,附录cron表达式介绍:CronTrigger

Crontriggers tend to be more useful than simpletrigger if you need a calendar-based concept, rather than simpletrigger a fully specified time interval, recurrence of the launch work schedule.
Crontrigger, you can specify a trigger schedule such as "Every Friday noon", or "every weekday 9:30", or even "every 5 minutes 9:00 and 10:00 per Monday a.m., Wednesday Friday".
Even so, like Simpletrigger, Crontrigger owns the starttime when the specified timesheet is in effect, and the specified timesheet should stop (optional) the end time.

Cron Expressions

The cron expression is used to configure the Crontrigger instance. The cron expression is a string, which is actually a schedule of seven sub-expressions that describe individual details. These sub-expressions are separate blanks, which represent:

    1.    Seconds
    2.    Minutes
    3.    Hours
    4.    Day-of-Month
    5.    Month
    6.    Day-of-Week
    7.    Year (可选字段)
      Example "0 0 12? * WED "executed every Wednesday 12:00,

Individual sub-expressions can contain ranges, for example, in the previous example ("WED") can be replaced by "Mon-fri", "MON, WED, FRI" or even "Mon-wed,sat".

"*" represents the entire time period.

Each field has a set of valid values that can be specified, such as

Seconds (seconds): can be represented by the number 0-59,

Minutes (min): can be represented by the number 0-59,

Hours (Time): can be represented by the number 0-23,

Day-of-month (days): You can use any of the one by one values in the number 1-31, but be aware of some special months

Month: can be used with 0-11 or string "JAN, FEB, MAR, APR, May, June, JUL, April, SEP, OCT, NOV and DEC" indicated

Day-of-week (Weekly): Can be denoted by the number 1-7 (1 = Sunday) or Fukou string "SUN, MON, TUE, WED, THU, FRI and SAT"

"/": For a special unit, expressed as "each", such as "0/15" means to execute every 15 minutes, "0" is expressed as starting from "0", "3/20" means to execute every 20 minutes, "3" for the 3rd minute start of execution

“?” : Indicates a day of the month, or a day of the week

"L": For each month, or weekly, expressed as the last day of the month, or the last week of each month as "6L" means "last Friday of the month"

"W": indicated as the most recent weekday, as "15W" is placed on the monthly (day-of-month) field as "the most recent working day of 15th this month"

"#": Is used to specify "the nth working day of the month, the example in the weekly (Day-of-week) This field is" 6#3 "or" fri#3 "means" the third Friday per month "

1) format of cron expression: second-time time-of-year (optional).

           Field name allowed value allowed special characters sec 0-59                     ,-*/min 0-59,-*/hour                               0-23,-*/day 1-31 , - * ? /L W C month 1-12 or JAN-DEC,-*/week 1-7 or SU N-sat,-*? /L C # Year (optional field) empty, 1970-2099,-*/"?" Character: Represents an indeterminate value "," character: Specifies a number of values "-" character: Specifies the range of a value "/" character: Specifies the increment of a value. N/m indicates that the M "L" character is incremented every time from N: Used on the last day of the one-month period, the week represents the last one weeks of the month X "W" characters: Specifies the most recent weekday (Monday to Friday) "#" character from the given date: the first few months of the month Week x.             6#3 represents the 3rd Friday 2) Cron Expression example: every 5 seconds: */5 * * * *?             Executes every 1 minutes: 0 */1 * * *?             Executed at 23 o ' Day: 0 0 23 * *?          Once daily 1 o'clock in the morning: 0 0 1 * *?   Every month, 1th, 1 o'clock in the morning, once: 0 0 1 1 *?             The last day of the month is executed at 23 points: 0 0 L *? Once a week, Sunday 1 o'clock in the morning: 0 0 1?             * L at 26, 29, 33 to execute once: 0 26,29,33 * * *? Every day 0, 13, 18, 21 points are executed once: 0 0 0,13,18,21 * *?

Reference: http://www.cnblogs.com/sunjie9606/archive/2012/03/15/2397626.html

Spring timed Task Configuration error

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.