`
morgan-java
  • 浏览: 56394 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

CronTrigger Exdivssions

阅读更多
CronTrigger Exdivssions



Cron-Exdivssions are used to configure instances of CronTrigger. Cron-Exdivssions are strings that are actually made up of six sub-exdivssions, that describe individual details of the schedule. These sub-exdivssion are separated with white-space, and redivsent:



Seconds

Minutes

Hours

Day-of-Month

Month

Day-of-Week



An example of a complete cron-exdivssion is the string "0 0 12 ? * WED" - which means "every Wednesday at 12:00 pm".



Individual sub-exdivssions can contain ranges and/or lists. For example, the day of week field in the divvious (which reads "WED") example could be replaces with "MON-FRI", "MON, WED, FRI", or even "MON-WED,SAT".



Wild-cards (the '*' character) can be used to say "every" possible value of this field. Therefore the '*' character in the "Month" field of the divvious example simply means "every month". A '*' in the Day-Of-Week field would obviously mean "every day of the week".



All of the fields have a set of valid values that can be specified. These values should be fairly obvious - such as the numbers 0 to 59 for seconds and minutes, and the values 0 to 23 for hours. Day-of-Month can be any value 0-31, but you need to be careful about how many days are in a given month! Months can be specified as values between 0 and 11, or by using the strings JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV and DEC. Days-of-Week can be specified as vaules between 1 and 7 (1 = Sunday) or by using the strings SUN, MON, TUE, WED, THU, FRI and SAT.



The '/' character can be used to specify increments to values. For example, if you put '0/15' in the Minutes field, it means 'every 15 minutes, starting at minute zero'. If you used '3/20' in the Minutes field, it would mean 'every 20 minutes during the hour, starting at minute three' - or in other words it is the same as specifying '3,23,43' in the Minutes field.



The '?' character 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. See the examples below (and CronTrigger JavaDOC) for clarification.



The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" or "FRIL" both mean "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.



Here are a few more examples of exdivssions and their meanings - you can find even more in the JavaDOC for CronTrigger



CronTrigger Example 1 - an exdivssion to create a trigger that simply fires every 5 minutes



  "0 0/5 * * * ?"



CronTrigger Example 2 - an exdivssion to create a trigger that fires every 5 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:05:10 am, etc.).



  "10 0/5 * * * ?"



CronTrigger Example 3 - an exdivssion to create a trigger that fires at 10:30, 11:30, 12:30, and 13:30, on every Wednesday and Friday.



  "0 30 10-13 ? * WED,FRI"



CronTrigger Example 4 - an exdivssion to create a trigger that fires every half hour between the hours of 8 am and 10 am on the 5th and 20th of every month. Note that the trigger will NOT fire at 10:00 am, just at 8:00, 8:30, 9:00 and 9:30



  "0 0/30 8-9 5,20 * ?"





Note that some scheduling requirements are too complicated to exdivss with a single trigger - such as "every 5 minutes between 9:00 am and 10:00 am, and every 20 minutes between 1:00 pm and 10:00 pm". The solution in this scenario is to simply create two triggers, and register both of them to run the same job.
分享到:
评论

相关推荐

    CronTrigger的未触发指令学习

    【标题】:“CronTrigger的未触发指令学习” 在任务调度的世界里,CronTrigger是Quartz库中的一个核心组件,用于根据特定的cron表达式执行任务。CronTrigger允许我们按照时间表(如每日、每周或每小时)来安排我们...

    CronTrigger

    ### CronTrigger 在 Spring Quartz 定时任务中的应用 #### 一、CronTrigger 概述 CronTrigger 是 Spring Quartz 框架中用于定义基于日历规则的任务调度的一种方式。与 SimpleTrigger 相比,CronTrigger 提供了更...

    CronTrigger配置格式

    CronTrigger是Quartz调度框架中的一个重要组件,用于根据预定义的时间规则触发任务。它的配置格式灵活且强大,能够满足各种复杂的定时需求。下面将详细解释CronTrigger的配置格式和通配符的使用。 配置格式如下: ...

    关于quartz中CronTrigger的使用说明

    ### 关于Quartz中CronTrigger的使用说明 在Quartz调度器中,`CronTrigger`是一种基于Cron表达式的触发器,它允许我们按照类似Unix/Linux操作系统中的Cron任务的方式来定义执行时间表。通过CronTrigger,我们可以...

    Quartz CronTrigger配置说明

    ### Quartz CronTrigger配置详解 #### 一、CronTrigger简介 CronTrigger 是 Quartz 调度器中一种非常强大的任务触发机制,它基于类似于 Unix cron 的表达式来定义任务的执行时间。CronTrigger 表达式由七个或八个...

    SpringBoot实现动态定时任务

    CronTrigger cronTrigger = trigger.reschedule(scheduler.getScheduler().getTrigger(triggerKey)); scheduler.schedule(task, cronTrigger); cronTriggers.put(taskName, cronTrigger); } } public void ...

    qutarz.使用方法

    CronTrigger cronTrigger = new CronTrigger("myTrigger", "myGroup", "myJob", "myJobGroup", new Date(), new Date(System.currentTimeMillis() + 365 * 24 * 60 * 60 * 1000), "0 0 9 ? * MON-FRI", TimeZone....

    Python库 | cron_schedule_triggers-0.0.4-py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:cron_schedule_triggers-0.0.4-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Quartz 表达式自动生成插件

    CronTrigger是Quartz中的一种触发器类型,它基于Unix的crontab语法,允许用户设置复杂的定时计划。 CronTrigger表达式是由七个子表达式组成的字符串,每个子表达式代表不同的时间元素:秒、分钟、小时、日、月份中...

    spring设置动态定时任务.pdf

    CronTrigger cronTrigger = (CronTrigger) scheduler.getTrigger(triggerKey); if (cronTrigger != null) { TriggerBuilder<CronTrigger> triggerBuilder = cronTrigger.getTriggerBuilder(); triggerBuilder....

    CronQuartz

    CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("myTrigger", "group1").withSchedule(scheduleBuilder).build(); ``` 3. 注册任务与触发器:然后,你需要在`Scheduler`实例中注册你的任务...

    CronTrigge

    ### CronTrigger 配置解析与应用 #### 一、CronTrigger 概述 CronTrigger 是一种基于时间的任务触发器,在Quartz等调度框架中广泛使用,它允许用户通过配置表达式来定义任务的执行周期。CronTrigger 的配置格式灵活...

    spring的定时任务的配置

    在此示例中,`schedulerFactory` 被配置为管理 `cronTrigger` 和 `cronTrigger2` 两个触发器。 #### 四、动态获取 Cron 表达式 在某些情况下,可能需要根据实际情况动态获取 Cron 表达式。可以通过 `...

    Quartz在Spring中动态设置cronExpression

    CronTrigger cronTrigger = (CronTrigger) scheduler.getTrigger("cronTriggerName", "groupName"); if (cronTrigger != null) { cronTrigger.setCronExpression(newCronExpression); scheduler.rescheduleJob...

    触发器 格式

    CronTrigger 是在 Quartz 或其他类似调度库中使用的一种高级定时任务触发器,它允许用户以更灵活的方式定义任务的执行时间。CronTrigger 基于传统的 Unix cron 表达式,这种表达式由七个子表达式组成,每个子表达式...

    hava 任务样例

    CronTrigger cronTrigger = TriggerBuilder.newTrigger() .withIdentity("myTrigger", "group1") .withSchedule(scheduleBuilder) .build(); // 创建 SchedulerFactory 和 Scheduler SchedulerFactory ...

    Quartz一个开源作业调度框架

    CronTrigger cronTrigger = TriggerBuilder.newTrigger() .withIdentity("cronTrigger", "group1") .withSchedule(CronScheduleBuilder.cronSchedule("0 0/5 * * * ?")) // 每5分钟执行一次 .build(); // 将 ...

    Quartz 多任务和单任务实现java源码

    Quartz SimpleTrigger CronTrigger java 源码 多任务 单任务实现 jobQuartz SimpleTrigger CronTrigger java 源码 多任务 单任务实现 job

    quartz java定时调度代码

    CronTrigger cronTrigger = (CronTrigger) TriggerBuilder.newTrigger() .withIdentity("myCronTrigger", "group1") .withSchedule(CronScheduleBuilder.cronSchedule("0 0 22 * * ?")) .build(); ``` 5. **持久...

    Spring Quartz可变参数Trigger

    CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerName); if (trigger != null) { TriggerBuilder<CronTrigger> updatedTrigger = trigger.getTriggerBuilder().withIdentity(trigger.getName()...

Global site tag (gtag.js) - Google Analytics