quartz一分钟教程 java任务调度
2009-11-27 12:19
471 查看
quartz是干啥的? 任务调度用的
任务调度是干啥的?就是在预定的时间做预定的事
1.在quart网站下最新的JAR包
2.建个项目,把quartz的JAR包加入到项目
3.新建一个任务
4.开启任务:
5.运行StartSchedule即可
其中:
"0/2 * * * * ?" 是cronExpression表达式
一共有7组数据组成,位与位之间用空间分隔
分别代表 “秒 分 时 日 月 周 年” 其中年是可以省略的,所以在例子中用了6组
官方的例子:
任务调度是干啥的?就是在预定的时间做预定的事
1.在quart网站下最新的JAR包
2.建个项目,把quartz的JAR包加入到项目
3.新建一个任务
public class MyJob implements org.quartz.Job { @Override public void execute(JobExecutionContext arg0) throws JobExecutionException { System.out.println("我被调用了"); } }
4.开启任务:
public class StartSchedule { public static void main(String[] args) throws Exception { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); JobDetail job = new JobDetail("job1", "group1", MyJob.class); CronTrigger t = new CronTrigger("trigger1", "group1", "job1", "group1", "0/2 * * * * ?"); sched.scheduleJob(job, t); sched.start(); Thread.sleep(500000); sched.shutdown(true); } }
5.运行StartSchedule即可
其中:
"0/2 * * * * ?" 是cronExpression表达式
一共有7组数据组成,位与位之间用空间分隔
分别代表 “秒 分 时 日 月 周 年” 其中年是可以省略的,所以在例子中用了6组
官方的例子:
Examples
Here are some full examples:Expression | Meaning |
---|---|
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 |
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. |
相关文章推荐
- (转)Java任务调度框架Quartz入门教程指南(二) 使用job、trigger、schedule调用定时任务
- (转)Java任务调度框架Quartz入门教程指南(四)Quartz任务调度框架之触发器精讲SimpleTrigger和CronTrigger、最详细的Cron表达式范例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- (转)Java任务调度框架Quartz入门教程指南(三)任务调度框架Quartz实例详解深入理解Scheduler,Job,Trigger,JobDetail
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz入门教程指南(二) 使用job、trigger、schedule调用定时任务
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度框架Quartz教程实例
- Java任务调度开源框架quartz学习
- java定时任务调度工具-quartz
- Java Quartz 构建定时调度任务
- Java 定时任务调度工具 Quartz(Part 2)
- java中任务调度java.util.Timer,ScheduledExecutor,Quartz的机制说明和demo代码实例分享
- Quartz - Java 任务调度