1.App.config
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<quartz>
<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzScheduler"/>
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="2"/>
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz"/>
<!--******************************Plugin配置*********************************************-->
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
<add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml"/>
</quartz>
2.根目录下quartz_jobs.xml,需调始终复制
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"> <processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives> <schedule> <!--开始执行一个调度-->
<job>
<name>RecyclingResourcesJob</name>
<group>RecyclingResourcesGroup</group>
<description>RecyclingResourcesJob</description>
<job-type>RecyclingResources.Jobs.RecyclingResourcesJob, RecyclingResources</job-type>
<durable>true</durable>
<recover>false</recover>
</job> <trigger>
<cron> <name>RecyclingResourcesJobTrigger</name>
<group>RecyclingResourcesJobTriggerGroup</group>
<job-name>RecyclingResourcesJob</job-name>
<job-group>RecyclingResourcesGroup</job-group> <cron-expression>0 */2 * * * ?</cron-expression>
</cron> </trigger>
<!--结束一个调度-->
</schedule>
</job-scheduling-data>
3.Cron表达式范例
每隔5秒执行一次:*/5 * * * * ? 每隔1分钟执行一次:0 */1 * * * ? 每天23点执行一次:0 0 23 * * ? 每天凌晨1点执行一次:0 0 1 * * ? 每月1号凌晨1点执行一次:0 0 1 1 * ? 每月最后一天23点执行一次:0 0 23 L * ? 每周星期天凌晨1点实行一次:0 0 1 ? * L 在26分、29分、33分执行一次:0 26,29,33 * * * ? 每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ?