【问题标题】:Cron trigger from 12:04 to 14:25从 12:04 到 14:25 的 Cron 触发器
【发布时间】:2011-01-05 02:01:49
【问题描述】:

是否可以为每天和每分钟从 12:04 到 14:25 触发的触发器编写 cron 表达式?

【问题讨论】:

    标签: triggers cron quartz-scheduler


    【解决方案1】:

    我认为最短的解决方案(使用 cron)是这 3 行

    4-59 12 * * * <command>
    0-59 13 * * * <command>
    0-25 14 * * * <command>
    

    他们定义了每小时的触发范围。

    【讨论】:

      【解决方案2】:

      您必须设置 3 个 diff cron 作业:

          .---------------- minute (0 - 59) 
          |  .------------- hour (0 - 23)
          |  |   .---------- day of month (1 - 31)
          |  |   |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
          |  |   |  |  .---- day of week  
          |  |   |  |  |
        4-59 12  *  *  *  <command to be executed>
        0-59 13  *  *  *  <command to be executed>
        0-25 14  *  *  *  <command to be executed>
      

      【讨论】:

        【解决方案3】:

        您标记了quartz,因此这里是一个取自http://quartz.sourceforge.net/javadoc/org/quartz/CronTrigger.html 文档的示例

        0 * 12-14 * * ? 会在每天 12:00 到 14:59 之间每分钟触发一次。

        从我链接到的网页中的示例"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 4-59,0-59,0-25 12,13,14 * * ?

        但我不确定这是否可行,因为它看起来有点可疑,并且文档没有说明如果你这样写分钟/小时是如何解释的。如果不起作用,则必须定义三个触发器:

        0 4-59 12 * * ?
        0 * 13 * * ?
        0 0-25 14 * * ?
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多