首页 > 解决方案 > 每小时在 50 到 60 分钟之间安排一次作业

问题描述

我正在尝试在春季使用@Schedule,我想知道是否可以选择使用 cron 在 50 分钟到 59 分钟之间每小时运行一次,例如:它将运行:13:58、14:52 , 15:57 16:50 等...

谢谢

标签: javaspringcronquartz-scheduler

解决方案


看这个例子:

0 50-59/1 * * *

从 crontab 手册页,第 5 节:

       field         allowed values
       -----         --------------
       minute        0-59
       hour          0-23
       day of month  1-31
       month         1-12 (or names, see below)
       day of week   0-7 (0 or 7 is Sun, or use names)

 A field may be an asterisk (*), which always stands for ``first-last''.

 Ranges of numbers are allowed.  Ranges are two numbers separated with a hyphen.  The specified range is inclusive.  For example, 8-11 for an
 ``hours'' entry specifies execution at hours 8, 9, 10 and 11.

 Lists are allowed.  A list is a set of numbers (or ranges) separated by commas.  Examples: ``1,2,5,9'', ``0-4,8-12''.

推荐阅读