You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cron表达式相似性判定与特定交替调度表达式构建问询

Cron Expression Analysis & Custom Schedule Solution

Are the three Cron expressions similar? Which are redundant?

All three expressions are identical in their execution behavior—they’ll trigger at 15, 35, and 55 minutes past every hour, every day, no exceptions. Here’s the breakdown:

  • Expression a: 15,35,55 * * * *
    The hour field uses *, which means "every hour" (0 through 23).

  • Expression b: 15,35,55 */1 * * *
    */1 in the hour field translates to "every 1 hour starting from the first valid hour (0)". This is functionally the same as * because stepping by 1 over the full 0-23 hour range covers every hour.

  • Expression c: 15,35,55 0/1 * * *
    0/1 means "start at hour 0, increment by 1 each time". This also covers every hour from 0 to 23, matching the behavior of * and */1.

Since all three do exactly the same thing, expressions b and c are redundant compared to a. Expression a is the most concise and standard way to write this schedule.

Custom Cron Schedule for the Desired Pattern

Your requested schedule follows a repeating rhythm:

  • Even-numbered hours (8, 10, 12, ..., 22): Trigger at 35 minutes past the hour
  • Odd-numbered hours (9, 11, 13, ..., 23): Trigger at 15 and 55 minutes past the hour

Standard Unix Cron doesn’t support conditional logic (like "if hour is even, use this minute; else use those minutes") in a single expression. The cleanest, most compatible solution is to use two separate Cron expressions:

  1. For even hours (runs at 35 past every even hour):

    35 */2 * * *
    
    • */2 in the hour field selects every 2nd hour starting from 0 (so 0, 2, 4, ..., 22—all even hours).
  2. For odd hours (runs at 15 and 55 past every odd hour):

    15,55 1-23/2 * * *
    
    • 1-23/2 in the hour field selects every 2nd hour starting from 1 (so 1, 3, 5, ..., 23—all odd hours).

If you’re using a Cron implementation with advanced syntax (like Quartz), you could combine these into one expression with logical OR, but the two-expression approach works with all standard Cron systems and is easier to read/maintain.

内容的提问来源于stack exchange,提问作者rethabile

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:00:09