简体   繁体   English

计划任务在给定时间每3天运行一次

[英]Scheduled task to run every 3 days at given time

I am using Quartz 2 scheduler for scheduling tasks. 我正在使用Quartz 2 Scheduler来计划任务。 Below is what I need. 以下是我需要的。

  1. schedule the job when the user click on a button. 用户单击按钮时安排工作。
  2. The job should be scheduled to run at 8 AM, every 3 days. 该作业应安排为每3天在上午8点运行。

Below is how I coded it. 以下是我的编码方式。 It will execute (with its scheduler of course) once the user click on a button in web app) 一旦用户单击Web应用程序中的按钮,它将执行(当然还有其调度程序)

Trigger passportTrigger1 = newTrigger()
                 .withIdentity(passportTriggerKey1)
                 .withSchedule(simpleSchedule().withIntervalInHours(3*24).repeatForever()) 
                 .startAt(todayAt(8,0,0)).build();

However you can see that I have used startAt(todayAt(8,0,0)) . 但是您可以看到我已经使用过startAt(todayAt(8,0,0)) What happens if the user turned on the scheduler after 8.00 AM today? 如果用户今天凌晨8:00打开调度程序,会发生什么情况? The job will be scheduled immediately or it will never get scheduled? 该作业将立即安排,还是永远不会安排?

您还可以检查当前时间:如果是在上午8点之前startAt(todayAt(8, 0, 0) startAt(tomorrowAt(8, 0, 0)) startAt(todayAt(8, 0, 0)否则startAt(tomorrowAt(8, 0, 0))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每N天在一天的特定时间运行任务的计划程序 - Scheduler for a task to run at particular hour of the day for every N days 安排Java中的任务每隔X天运行一次或仅执行一次 - Scheduling a task in Java to run every X days or execute once only 时间选择器每分钟执行安排的任务,直到达到设置的时间,而不是仅在设置的时间执行 - Time picker performs scheduled task every minute until set time is reached instead of performing it only at set time 如何使用Java在一周中的特定日期的特定时间运行任务? - How to run a task on specific days of the week at a certain time in java? 每天运行一次计划任务 - run a scheduled task once a day 在特定日期使用 (Spring @Scheduled) 运行作业 - Run a job with (Spring @Scheduled) on specific days 如何使用 ScheduledExecutorService 每天在特定时间运行某些任务? - How to run certain task every day at a particular time using ScheduledExecutorService? 在 window 期间每 30 分钟运行一次任务 - Run a task every 30 min during time window 如何将Spring Scheduled Task配置为在特定延迟的时间范围内运行? - How can I configure Spring Scheduled Task to run in a time range with specific delay? 是否可以将带有Spring @Scheduled批注的作业安排为每小时运行一次,但每次随机运行一次? - Is it possible to schedule a job with Spring @Scheduled annotation to run every hour but each time at random hour?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM