1. 从XML文件创建作业

    最新版本的quartz.net支持直接从xml文件创建作业,使用起来很方便.配置文件的格式可以参考下面的例子

    <?xml version="1.0" encoding="UTF-8"?>
    <quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     version="1.0"
                    overwrite-existing-jobs="true">
      <job>
        <job-detail>
          <name>CaiJiJob</name>
          <group>jobGroup1</group>
          <job-type>WAT.PMS.JOB.Job.CaiJiJob, WAT.PMS.JOB</job-type>       
        </job-detail>

        <trigger>
          <simple>
            <name>simpleName</name>
            <group>simpleGroup</group>
            <description>SimpleTriggerDescription</description>  
            <job-name>jobName1</job-name>
            <job-group>jobGroup1</job-group>
            <start-time>1982-06-28T18:15:00.0Z</start-time>       
            <repeat-count>0</repeat-count>
          </simple>
        </trigger>
      </job>
      <job>
        <job-detail>
          <name>SavaDataJob</name>
          <group>jobGroup2</group>
          <job-type>WAT.PMS.JOB.Job.SaveDataJob, WAT.PMS.JOB</job-type>
        </job-detail>

        <trigger>
          <cron>
            <name>cronName2</name>
            <group>cronGroup2</group>
            <job-name>jobName2</job-name>
            <job-group>jobGroup2</job-group>
            <start-time>1982-06-28T18:15:00+02:00</start-time>
            <cron-expression>0 0/2 * * * ?</cron-expression>
          </cron>
        </trigger>
      </job>
    </quartz>

  2. Cron表达式知识

    "Cron-Expression"由6到7个用空格分开的字段组成的表达式这6或7个字段必须遵循下面的顺序和格式:

    Seconds 0-59 , - * /
    Minutes 0-59 ,- * /
    Hours 0-23 , - * /
    Day-of-month 1-31 , - * ? / L W C
    Month 1-12 or JAN-DEC , - * /
    Day-of-Week 1-7 or SUN-SAT , - * ? / L C #
    Year (Optional) empty, 1970-2099 , - * /
    *是一个通配符,表示任何值,用在Minutes字段中表示每分钟。
    ?只可以用在day-of-month或者Day-of-Week字段中,用来表示不指定特殊的值。
    -用来表示一个范围,比如10-12用在Month中表示10到12月。
    ,用来表示附加的值,比如MON,WED,FRI在day-of-week字段中表示礼拜一和礼拜三和礼拜五。
    /用来表示增量,比如0/15用在Minutes字段中表示从0分开始0和15和30和45分。
    L只可以用在day-of-month或者Day-of-Week字段中,如果用在Day-of-month中,表示某个月的最后一天,1月则是表示31 号,2月则表示28号(非闰年),如果用在Day-of-Week中表示礼拜六(数字7);但是如果L与数字组合在一起用在Day-of-month中, 比如6L,则表示某个月的最后一个礼拜六;

     

    0 1 0 1 1-12 ?表示每月1号0点1分执行。
    0 0 21 ? * 1表示每个礼拜天 21点0分执行。
    0 0 0 * * ?表示每天0点0分执行。
    0 * 22 * * ?表示每天22点开始每分钟
    0 * 0-23 * * ?表示每天每分钟(0 * * * * ? 不可以???Doltter注释)

     

字段

 

允许值

 

允许的特殊字符

 

0-59

 

, - * /

 

0-59

 

, - * /

小时

 

0-23

 

, - * /

日期

 

1-31

 

, - * ? / L W C

月份

 

1-12 或者 JAN-DEC

 

, - * /

星期

 

1-7 或者 SUN-SAT

 

, - * ? / L C #

年(可选)

 

留空, 1970-2099

 

, - * /

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 ? * 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

  

 

Quartz.net配置文件实例及cron表达式详解的更多相关文章

  1. (2)Spring集成Quartz定时任务框架介绍和Cron表达式详解

    在JavaEE系统中,我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.我们可以使用java.util.Timer结合java.util.TimerTask来完成这项工作,但 ...

  2. Spring集成Quartz定时任务框架介绍和Cron表达式详解

    原文地址:http://www.cnblogs.com/obullxl/archive/2011/07/10/spring-quartz-cron-integration.html 在JavaEE系统 ...

  3. Spring_Spring集成Quartz定时任务框架介绍和Cron表达式详解

    在JavaEE系统中,我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.我们可以使用java.util.Timer结合java.util.TimerTask来完成这项工作,但 ...

  4. Quartz.Net系列(九):Trigger之CronScheduleBuilder和Cron表达式详解

    1.使用 var scheduler =await StdSchedulerFactory.GetDefaultScheduler(); await scheduler.Start(); var jo ...

  5. Cron表达式详解和表达式的验证

    本篇不算原创,因为主要内容来自网上的博客,所以给出我参考文章的链接. 本文cron表达式详解的大部分内容参考了[cron表达式详解]和Quartz使用总结.Cron表达式 这两篇文章. cron校验的 ...

  6. cron表达式详解

    @Scheduled(cron = "* * * * * *") cron表达式详解 1.cron表达式格式: {秒数} {分钟} {小时} {日期} {月份} {星期} {年份( ...

  7. spring定时任务(@Scheduled注解)cron表达式详解

    cron表达式详解: 一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素. 按顺序依次为 秒(~) 分钟(~) 小时(~) 天(~) 月(~) 星期(~ =SUN 或 SUN,MON,TU ...

  8. crontab和cron表达式详解

    引言 我们在定时任务中经常能接触到cron表达式,但是在写cron表达式的时候我们会遇到各种各样版本的cron表达式,比如我遇到过5位.6位甚至7位的cron表达式,导致我一度搞混这些表达式.更严重的 ...

  9. quartz.net 时间表达式----- Cron表达式详解

    序言 Cron表达式:就是用简单的xxoo符号按照一定的规则,就能把各种时间维度表达的淋漓尽致,无所不在其中,然后在用来做任务调度(定时服务)的quart.net中所认知执行,可想而知这是多么的天衣无 ...

随机推荐

  1. 改变textView的个别字体颜色

    Spannable span = new SpannableString(getString(R.string.register_need_to_ageree));//例如:register_need ...

  2. Oracle_SQL函数-分组函数

    分组函数 什么是分组函数 分组函数作用于一组数据,并对一组数据返回一个值 组函数类型:主要有6种 AVG - 平均 COUNT - 计数 MAX - 最大 MIN - 最小 SUM - 求和 STDD ...

  3. Connect(); // 2015 简要整理

    去年 Connect(); 2014 Visual Studio Contact(); 直播笔记 对于我个人来说,今年 Connect(); 的三个重要发布: ASP.NET 5 RC1 Entity ...

  4. MAT使用--转

    原文地址: [1]http://ju.outofmemory.cn/entry/172684 [2]http://ju.outofmemory.cn/entry/129445 MAT使用入门 MAT简 ...

  5. 项目总结---- imageLoder 的2个Bug解决方法、1.9.4如何选择性删除disk缓存和其它一些错误。

    我们不说废话,直接入主题,抓紧时间写完,好继续找bug... (PS:imageLoder的bug 百度不到的哦,不过我坚信我的观点没错) 版本1.9.2,1.9.4我没测试 1,imageLoder ...

  6. swift 的高阶函数的使用代码

    //: Playground - noun: a place where people can play import UIKit var str = "Hello, playground& ...

  7. ar命令详解

    ar 命令 用途 维护链接编辑器使用的索引库. 语法 ar [  -c ] [  -l ] [  -g | -o ] [  -s ] [  -v ] [  -C ] [  -T ] [  -z ] { ...

  8. CSS中position的4种定位详解

    大家都知道,css中的position有4种取值,分别是static.fixed.relative.absolute. 详细解释: static:相当于没有定位,元素会出现在正常的文档流中. fixe ...

  9. 学习Linux下s3c2440的USB鼠标驱动笔记

    1.ARM-Linux下USB驱动程序开发1.1.1.linux下USB配置:*********(MassStorage:存储设备)********************************** ...

  10. (十七)WebGIS中距离及面积测量的原理和实现以及坐标转换的简单介绍

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 在这一章里我们将讨论基础工具栏中另外两个常用工具:距离测量工 ...