quartz

quartz(由java编写的开源作业调度框架)

|
|-核心接口:org.quartz.Job
|-核心方法:public void execute(JobExecutionContext context) throws JobExecutionException;
|
|-作业实现步骤|--编写作业类,实现Job接口,重写execute方法
|             |
|             |--添加一些逻辑到execute()方法
|             |
|             |--一旦你配置好Job实现类并设定好调度时间表,Quartz将密切注意剩余时间
|             |
|             |--当调度程序确定该是通知你的作业的时候,Quartz框架将调用作业类上的execute()方法并允许做它该做的事情
|
|-调度器|--Quartz框架的核心
|       |--调度器负责管理Quartz应用运行时环境。
|       |--调度器不是靠自己做所有的工作,而是依赖框架内一些非常重要的部件。
|       |--Quartz不仅仅是线程和线程管理。
|       |--为确保可伸缩性,Quartz采用了基于多线程的架构。
|       |--启动时,框架初始化一套worker线程,这套线程被调度器用来执行预定的作业。
|       |--这就是Quartz怎样能并发运行多个作业的原理。
|       |--Quartz依赖一套松耦合的线程池管理部件来管理线程环境。
|
|-Quartz经常会用到cron表达式,可以使用国外网站cronmaker辅助生成cron表达式。

cron表达式

|
|-用于配置CronTrigger实例.
|
|-由七个子字符串组成一个大字符串|--Seconds                |0 to 59
|  (子串之间空格分割)           |--Minutes                |0 to 59
|                               |--Hours                  |0 to 23
|                               |--Day-of-Month           |1 to 31
|                               |--Month                  |0 to 11 ,or by using the strings JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV and DEC
|                               |--Day-of-Week            |1 to 7 (1 = Sunday),or by using the strings SUN, MON, TUE, WED, THU, FRI and SAT
|                               |--Year (optional field)  |
|                                                
|-示例,"0 0 12 ? * WED" : 表示 "every Wednesday at 12:00:00 pm"
|
|-字串规则|--1.可以是range或list集合,:"MON-FRI", "MON,WED,FRI", or even "MON-WED,SAT"
|         |
|         |--2.通配符(*)可以表示任意(every)
|         |    A '*' in the Day-Of-Week field would therefore obviously mean "every day of the week".
|         |
|         |--3.通配符(/) can be used to specify increments to values
|         |    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'.
|         |    "/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'.
|         |--4.通配符(?) is allowed for the day-of-month and day-of-week fields.
|         |    It is used to specify "no specific value". 
|         |    This is useful when you need to specify something in one of the two fields, but not the other. 
|		  |  
|         |--5.通配符(L) 可用于 day-of-month 和 day-of-week 字段,"last"的简写.
|         |           |
|         |           |---单独用于 day-of-month:表示月的最后一天
|         |           |---和数字组合用于 day-of-month:比如“L-3,表示the third-to-last day of the calendar month. 
|         |           |
|         |           |---单独用于 day-of-week :表示7"SAT" (周六)
|         |           |---和数字组合用于 day-of-week:表示“the last xxx day of the month” - for example “6L” or “FRIL” both mean “the last friday of the month”. 
|         |
|         |--6.通配符(W) 可以用于weekday (Monday-Friday 工作日) nearest the given day. 
|         |           |
|         |           |---比如“15W”用于day-of-month: 表示离15号最近的一个工作日
|         |
|         |--7.通配符(#) “the nth” XXX weekday of the month. 
|         |           |
|         |           |---比如“6#3” or “FRI#3”用于day-of-week:表示“the third Friday of the month”.
|
|-参考:http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-06.html

扩展问题

I want a cron expression which fires every 45 minutes.

According to the documentation, I have created this 0 0/45 * * * ? expression.

But it is fired in a pattern like 12:00, 12:45, 13:00, 13:45, 14:00.

But what I expect and want is to be fired at 12:00, 12:45, 13:30, 14:15.

What am I missing?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值