cron 是一个已经存在了很长时间的 UNIX 工具,因此它的调度能力很强大 并得到证明。CronTrigger 类基于 cron 的调度功能。

CronTrigger 使用“cron 表达式”,它能够创建触发时间表,例如:“在上午 8:00 每个 周一至周五“或”每月最后一个星期五凌晨 1:30”。

cron 表达式很强大,但可能会非常令人困惑。你可以使用这个工具直接进行转换

在线Cron表达式生成器 (qqe2.com)https://cron.qqe2.com/

1、cron 表达式

语法:秒 分 时 日 月 周 年(Spring 不支持)

Cron Trigger TutorialA full-featured, Java-based, In-process job scheduler.http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html

 特殊字符: ,:枚举;

(cron="7,9,23 * * * * ?"):任意时刻的 7,9,23 秒启动这个任务;

-:范围:

(cron="7-20 * * * * ?"):任意时刻的 7-20 秒之间,每秒启动一次

*:任意; 指定位置的任意时刻都可以

/:步长;

(cron="7/5 * * * * ?"):第 7 秒启动,每 5 秒一次;

(cron="*/5 * * * * ?"):任意秒启动,每 5 秒一次; ?:(出现在日和周几的位置):为了防止日和周冲突,在周和日上如果要写通配符使 用? (cron="* * * 1 * ?"):每月的 1 号,启动这个任务;

L:(出现在日和周的位置)”,

last:最后一个

(cron="* * * ? * 3L"):每月的最后一个周二

W:

Work Day:工作日

(cron="* * * W * ?"):每个月的工作日触发

(cron="* * * LW * ?"):每个月的最后一个工作日触发

#:第几个

(cron="* * * ? * 5#2"):每个月的第 2 个周 4

2、cron 示例

0 0 12 * * ? Fire at 12pm (noon) every day
0 15 10 ? * * Fire at 10:15am every day
0 15 10 * * ? Fire at 10:15am every day
0 15 10 * * ? * Fire at 10:15am every day
0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
0 * 14 * * ? Fire every minute starting at 2pm and ending at 2:59pm, every day
0 0/5 14 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
0 0/5 14,18 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
0 0-5 14 * * ? Fire every minute starting at 2pm and ending at 2:05pm, every day
0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
0 15 10 15 * ? Fire at 10:15am on the 15th day of every month
0 15 10 L * ? Fire at 10:15am on the last day of every month
0 15 10 L-2 * ? Fire at 10:15am on the 2nd-to-last last day of every month
0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
0 15 10 ? * 6L 2002-2005 Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
0 15 10 ? * 6#3 Fire at 10:15am on the third Friday of every month
0 0 12 1/5 * ? Fire at 12pm (noon) every 5 days every month, starting on the first day of the month.
0 11 11 11 11 ? Fire every November 11th at 11:11am.

cron 表达式解读相关推荐

  1. cron表达式,看这篇就够了

    一个bug 昨天下午写了个定时器,遇到了个离谱的问题?!原本想让定时器每五分钟跑一次,结果启动之后迟迟不跑?研究一番之后,才发现之前对cron表达式的理解是错误的. 我是这样写的:0 5 * * * ...

  2. 定时任务Cron表达式学习

    有关定时任务Cron表达式的那些 背景:今天在做quartZ定时任务,发现了要用Cron表达式去指定出发的时间表. 1.CronTrigger CronTrigger,你可以指定触发的时间表如&quo ...

  3. Cron 表达式极速参考

    Cron表达式: * * * * * * * 这些星号由左到右按顺序代表 : [秒] [分] [小时] [日] [月] [周] [年] 序号 说明    是否必填   允许填写的值         允 ...

  4. 定时任务 Cron表达式

    Cron表达式是一个表示时间周期的字符串. 分为6或7个域,每一个域代表一个含义. 验证工具: http://cron.qqe2.com/ Cron有如下两种语法格式: 格式1: 秒 分 时 天(月) ...

  5. 作业调度框架 Quartz 学习笔记(三) -- Cron表达式

    2019独角兽企业重金招聘Python工程师标准>>> 前面两篇说的是简单的触发器(SimpleTrigger) , SimpleTrigger 只能处理简单的事件出发,如果想灵活的 ...

  6. Quartz.Net cron表达式详解

    一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素. 按顺序依次为 1.秒(0~59) 2.分钟(0~59) 3.小时(0~23) 4.天(月)(0~31,但是你需要考虑月的天数) 5.月 ...

  7. Quartz cron表达式

    为什么80%的码农都做不了架构师?>>>    Cron表达式有以下两种语法格式: 1.     Seconds Minutes Hours DayofMonth Month Day ...

  8. 9点到17点半 cron_SpringQuartz定时任务的cron表达式书写

    SpringQuartz定时任务的使用,要配置这个定时任务什么时候执行,周期是多少,周期内执行多少次,这个都是cron表达式来控制的,下面详解一下这个cron表达式. 一.先来举些例子 [1]0 0 ...

  9. Spring 定时任务之 @Scheduled cron表达式

    首先在配置文件头部的必须要有: xmlns:task="http://www.springframework.org/schema/task" 1 其次xsi:schemaLoca ...

最新文章

  1. 如何有效使用每一点脑力总结_如何更有效地节省脑力和编码
  2. 如何保证MongoDB的安全性?
  3. MONGODB 集群架构 调整,增加延迟备份节点服务器,删除仲裁节点
  4. [Kali][VMware][2020][窗口大小][分辨率]高分辨率自适应
  5. leetCode 206. Reverse Linked List 反转链表
  6. 14.4.3.5 Configuring InnoDB Buffer Pool Flushing 配置InnoDB Buffer Pool 刷新:
  7. 未来数据中心核心技术:RDMA在京东的应用
  8. 较常用的Math方法及ES6中的扩展
  9. 支付宝开放平台开发助手_支付宝:如何创建和接入支付宝电脑网站支付-新手必备...
  10. 开博第二篇-win7下的小凡模拟器-DynamipsGUI
  11. Android studio :Android finished with non-zero exit value 1
  12. [收集]代码段(Code Snippets)
  13. js 正则表达式匹配定义及使用
  14. 使用 Jupyter Notebook
  15. 深度XP完美精简版 (适合低配置电脑)——迅雷
  16. c语言二级考试题库及答案,c语言二级考试题库
  17. 浪潮服务器销售案例ppt,浪潮服务器产品线介绍(ppt 105页)
  18. 字符串intern()方法详解
  19. No bootable device
  20. speedoffice表格如何全选表格

热门文章

  1. ensp:使用路由器实现网间通信
  2. 听完计算机讲座的感想,听讲座心得体会5篇
  3. 前端如何处理十万级别的大量数据
  4. Qt UI界面美化教程1:【“飞扬青云” Qt精美控件】使用教程1
  5. 知道创宇 二级安全公司 骗取面试人源码,长见识了啊。
  6. css 背景效果_前端教程 :20个CSS的常用套路附demo的效果实现与源码
  7. matlab app designer使用心得
  8. Unity和Cocos2D在2D游戏开发上的对比
  9. 非 root 用户手动编译安装 GCC
  10. 路由器重温——静态路由