V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
sockball07
V2EX  ›  程序员

crontab 的 week 位置给定 */2 该如何理解?

  •  
  •   sockball07 · Jul 30, 2020 · 2442 views
    This topic created in 2098 days ago, the information mentioned may be changed or developed.

    如 30 1 * * */2

    https://crontab.guru/#30_1___*/2

    为什么结果是...

    next at 2020-08-01 01:30:00
    then at 2020-08-02 01:30:00
    then at 2020-08-04 01:30:00
    then at 2020-08-06 01:30:00
    then at 2020-08-08 01:30:00
    

    再下面应该是 08-09 、08-11...?

    4 replies    2020-07-30 21:50:41 +08:00
    rrfeng
        1
    rrfeng  
       Jul 30, 2020   ❤️ 1
    0 1 2 3 4 5 6 整除 2
    arfa
        2
    arfa  
       Jul 30, 2020   ❤️ 1
    就是周二,周四,周六执行,周日可以算 0 也可以算 7,所以都执行
    linvon
        3
    linvon  
       Jul 30, 2020   ❤️ 1
    每周第 x/2==0 天运行,每周天数取值 0-6
    sockball07
        4
    sockball07  
    OP
       Jul 30, 2020
    想了想 其实还是有 "每‘" 的概念,要用代码实现就是用整除来做

    只是表达起来不能像前面的 每分钟、每小时那么直白
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5396 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 08:06 · PVG 16:06 · LAX 01:06 · JFK 04:06
    ♥ Do have faith in what you're doing.