Spring--quartz中cronExpression配置说明
我的淘宝店http://shop60787115.taobao.com/
字段允许值允许的特殊字符
秒0-59,-*/
分0-59,-*/
小时0-23,-*/
日期1-31,-*?/LWC
月份1-12或者JAN-DEC,-*/
星期1-7或者SUN-SAT,-*?/LC#
年(可选)留空,1970-2099,-*/
The'*'characterisusedtospecifyallvalues.Forexample,"*"intheminutefieldmeans"everyminute".
“*”字符被用来指定所有的值。如:”*“在分钟的字段域里表示“每分钟”。
The'?'characterisallowedfortheday-of-monthandday-of-weekfields.Itisusedtospecify'nospecificvalue'.Thisisusefulwhenyouneedtospecifysomethinginoneofthetwofileds,butnottheother.Seetheexamplesbelowforclarification.
“?”字符只在日期域和星期域中使用。它被用来指定“非明确的值”。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。看下面的例子你就会明白。
月份中的日期和星期中的日期这两个元素时互斥的一起应该通过设置一个问号(?)来表明不想设置那个字段
The'-'characterisusedtospecifyrangesForexample"10-12"inthehourfieldmeans"thehours10,11and12".
“-”字符被用来指定一个范围。如:“10-12”在小时域意味着“10点、11点、12点”。
The','characterisusedtospecifyadditionalvalues.Forexample"MON,WED,FRI"intheday-of-weekfieldmeans"thedaysMonday,Wednesday,andFriday".
“,”字符被用来指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”.
The'/'characterisusedtospecifyincrements.Forexample"0/15"inthesecondsfieldmeans"theseconds0,15,30,and45".And"5/15"inthesecondsfieldmeans"theseconds5,20,35,and50".Specifying'*'beforethe'/'isequivalenttospecifying0isthevaluetostartwith.Essentially,foreachfieldintheexpression,thereisasetofnumbersthatcanbeturnedonoroff.Forsecondsandminutes,thenumbersrangefrom0to59.Forhours0to23,fordaysofthemonth0to31,andformonths1to12.The"/"charactersimplyhelpsyouturnonevery"nth"valueinthegivenset.Thus"7/6"inthemonthfieldonlyturnsonmonth"7",itdoesNOTmeanevery6thmonth,pleasenotethatsubtlety.
The'L'characterisallowedfortheday-of-monthandday-of-weekfields.Thischaracterisshort-handfor"last",butithasdifferentmeaningineachofthetwofields.Forexample,thevalue"L"intheday-of-monthfieldmeans"thelastdayofthemonth"-day31forJanuary,day28forFebruaryonnon-leapyears.Ifusedintheday-of-weekfieldbyitself,itsimplymeans"7"or"SAT".Butifusedintheday-of-weekfieldafteranothervalue,itmeans"thelastxxxdayofthemonth"-forexample"6L"means"thelastfridayofthemonth".Whenusingthe'L'option,itisimportantnottospecifylists,orrangesofvalues,asyou'llgetconfusingresults.
L是‘last’的省略写法可以表示day-of-month和day-of-week域,但在两个字段中的意思不同,例如day-of-month域中表示一个月的最后一天,
如果在day-of-week域表示‘7’或者‘SAT’,如果在day-of-week域中前面加上数字,它表示一个月的最后几天,例如‘6L’就表示一个月的最后一个
星期五,
The'W'characterisallowedfortheday-of-monthfield.Thischaracterisusedtospecifytheweekday(Monday-Friday)nearestthegivenday.Asanexample,ifyouweretospecify"15W"asthevaluefortheday-of-monthfield,themeaningis:"thenearestweekdaytothe15thofthemonth".Soifthe15thisaSaturday,thetriggerwillfireonFridaythe14th.Ifthe15thisaSunday,thetriggerwillfireonMondaythe16th.Ifthe15thisaTuesday,thenitwillfireonTuesdaythe15th.Howeverifyouspecify"1W"asthevalueforday-of-month,andthe1stisaSaturday,thetriggerwillfireonMondaythe3rd,asitwillnot'jump'overtheboundaryofamonth'sdays.The'W'charactercanonlybespecifiedwhentheday-of-monthisasingleday,notarangeorlistofdays
.
The'L'and'W'characterscanalsobecombinedfortheday-of-monthexpressiontoyield'LW',whichtranslatesto"lastweekdayofthemonth".
The'#'characterisallowedfortheday-of-weekfield.Thischaracterisusedtospecify"thenth"XXXdayofthemonth.Forexample,thevalueof"6#3"intheday-of-weekfieldmeansthethirdFridayofthemonth(day6=Fridayand"#3"=the3rdoneinthemonth).Otherexamples:"2#1"=thefirstMondayofthemonthand"4#5"=thefifthWednesdayofthemonth.Notethatifyouspecify"#5"andthereisnot5ofthegivenday-of-weekinthemonth,thennofiringwilloccurthatmonth.
The'C'characterisallowedfortheday-of-monthandday-of-weekfields.Thischaracterisshort-handfor"calendar".Thismeansvaluesarecalculatedagainsttheassociatedcalendar,ifany.Ifnocalendarisassociated,thenitisequivalenttohavinganall-inclusivecalendar.Avalueof"5C"intheday-of-monthfieldmeans"thefirstdayincludedbythecalendaronorafterthe5th".Avalueof"1C"intheday-of-weekfieldmeans"thefirstdayincludedbythecalendaronoraftersunday".
关于cronExpression的介绍:
字段允许值允许的特殊字符
秒0-59,-*/
分0-59,-*/
小时0-23,-*/
日期1-31,-*?/LWC
月份1-12或者JAN-DEC,-*/
星期1-7或者SUN-SAT,-*?/LC#
年(可选)留空,1970-2099,-*/
表达式意义
"0012**?"每天中午12点触发
"01510?**"每天上午10:15触发
"01510**?"每天上午10:15触发
"01510**?*"每天上午10:15触发
"01510**?2005"2005年的每天上午10:15触发
"0*14**?"在每天下午2点到下午2:59期间的每1分钟触发
"00/514**?"在每天下午2点到下午2:55期间的每5分钟触发
"00/514,18**?"在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发
"00-514**?"在每天下午2点到下午2:05期间的每1分钟触发
"010,4414?3WED"每年三月的星期三的下午2:10和2:44触发
"01510?*MON-FRI"周一至周五的上午10:15触发
"0151015*?"每月15日上午10:15触发
"01510L*?"每月最后一日的上午10:15触发
"01510?*6L"每月的最后一个星期五上午10:15触发
"01510?*6L2002-2005"2002年至2005年的每月的最后一个星期五上午10:15触发
"01510?*6#3"每月的第三个星期五上午10:15触发
每天早上6点
06***
每两个小时
0*/2***
晚上11点到早上8点之间每两个小时,早上八点
023-7/2,8***
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0114*1-3
1月1日早上4点
0411*
quartz的高级特性不仅如此
1数据库存储
2集群支持
3数据库持久化任务,trigger
4trigger的停止,运行
5任务的任意添加
6比corntrigger更详尽的任务安排
7线程的内部数据交换
我的淘货之家http://taohuojia.taoke.bz/