码迷,mamicode.com
首页 > Web开发 > 详细

Quartz.net配置文件实例及cron表达式详解

时间:2014-07-29 21:36:32      阅读:418      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   使用   strong   文件   

  1. 从XML文件创建作业

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

    <?xml?version="1.0"?encoding="UTF-8"?>
    bubuko.com,布布扣<quartz?xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
    bubuko.com,布布扣????????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    bubuko.com,布布扣?????????????????version="1.0"
    bubuko.com,布布扣????????????????overwrite-existing-jobs="true">
    bubuko.com,布布扣??<job>
    bubuko.com,布布扣????<job-detail>
    bubuko.com,布布扣??????<name>CaiJiJob</name>
    bubuko.com,布布扣??????<group>jobGroup1</group>
    bubuko.com,布布扣??????<job-type>WAT.PMS.JOB.Job.CaiJiJob,?WAT.PMS.JOB</job-type>???????
    bubuko.com,布布扣????</job-detail>
    bubuko.com,布布扣
    bubuko.com,布布扣????<trigger>
    bubuko.com,布布扣??????<simple>
    bubuko.com,布布扣????????<name>simpleName</name>
    bubuko.com,布布扣????????<group>simpleGroup</group>
    bubuko.com,布布扣????????<description>SimpleTriggerDescription</description>??
    bubuko.com,布布扣????????<job-name>jobName1</job-name>
    bubuko.com,布布扣????????<job-group>jobGroup1</job-group>
    bubuko.com,布布扣????????<start-time>1982-06-28T18:15:00.0Z</start-time>???????
    bubuko.com,布布扣????????<repeat-count>0</repeat-count>
    bubuko.com,布布扣??????</simple>
    bubuko.com,布布扣????</trigger>
    bubuko.com,布布扣??</job>
    bubuko.com,布布扣??<job>
    bubuko.com,布布扣????<job-detail>
    bubuko.com,布布扣??????<name>SavaDataJob</name>
    bubuko.com,布布扣??????<group>jobGroup2</group>
    bubuko.com,布布扣??????<job-type>WAT.PMS.JOB.Job.SaveDataJob,?WAT.PMS.JOB</job-type>
    bubuko.com,布布扣????</job-detail>
    bubuko.com,布布扣
    bubuko.com,布布扣????<trigger>
    bubuko.com,布布扣??????<cron>
    bubuko.com,布布扣????????<name>cronName2</name>
    bubuko.com,布布扣????????<group>cronGroup2</group>
    bubuko.com,布布扣????????<job-name>jobName2</job-name>
    bubuko.com,布布扣????????<job-group>jobGroup2</job-group>
    bubuko.com,布布扣????????<start-time>1982-06-28T18:15:00+02:00</start-time>
    bubuko.com,布布扣????????<cron-expression>0?0/2?*?*?*??</cron-expression>
    bubuko.com,布布扣??????</cron>
    bubuko.com,布布扣????</trigger>
    bubuko.com,布布扣??</job>
    bubuko.com,布布扣</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表达式详解,布布扣,bubuko.com

Quartz.net配置文件实例及cron表达式详解

标签:des   style   blog   http   color   使用   strong   文件   

原文地址:http://www.cnblogs.com/meceky/p/3876265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!