这些cron表达式是否等同? [英] Are these cron expressions equivalent?

查看:234
本文介绍了这些cron表达式是否等同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间是否有任何差异

  * / 5 * * * *< COMMAND> 

  0/5 * * * *< COMMAND> 

解决方案<




  • 每隔5分钟执行一次, >
  • 第二个将在分钟0,5,10,... 55执行。



只有第一次在第5分钟执行第一次,他们将有相同的行为。






每5分钟可写成这样:

  0,5,10,15,20,25,30,35,40,45 ,50,55 * * * *< COMMAND> 

  0/5 * * * *< COMMAND> 

  * / 5 * * * *< COMMAND> 

无论如何,最后一个将开始任何时间的分钟变化,然后保持5分钟到下一个距离

$ <$>
/ strong>。如果是单独的,它将意味着每分钟,每小时等。



/ 字符可用于指定值的增量。如果我们表示 X / Y ,则表示从第X分钟开始每隔Y分钟。




  • 0/15 = 每小时第15分钟,从分钟零开始 = 0,15,30,45

  • 3/20 = 每20分钟小时,从第三分钟开始 = 3,23,43

  • / 40 = 每小时的第40分钟 = 40

  • 3/40 = 每小时第40分钟,从第三分钟开始 = 43
  • $回到你的问题,两个运算符的使用得到以下结果:



    code> * / 5
    =每5分钟开始一次。这样,每当更改分钟时,它将启动,并在5分钟,10等之后重复。



    0/5 =每5分钟从分钟0开始。它将在内部考虑为:0,5,10,15,20,25,30,35,40,45,50,55,因为这些是适合条件<






    有些参考资料:




    Is there any diffenrence between

    */5 * * * * <COMMAND>
    

    and

    0/5 * * * * <COMMAND>
    

    ?

    解决方案

    It is not the same.

    • The first one will be executed every 5 minutes starting any moment, while
    • the second one will be executed on minutes 0, 5, 10,... 55.

    Only if the first one is executed on minute 5k for the first time, they will have the same behaviour.


    Every 5 minutes can be written like this:

    0,5,10,15,20,25,30,35,40,45,50,55 * * * * <COMMAND>
    

    this

    0/5 * * * * <COMMAND>
    

    or

    */5 * * * * <COMMAND>
    

    Anyway, last one will start any time the minute changes and then keep a distance of 5 minutes to next execution.


    The * character means every. If it is alone, it will mean every minute, every hour, etc.

    The / character can be used to specify increments to values. If we indicate X/Y it means every Y minutes starting at minute X.

    • 0/15 = every 15th minute of the hour, starting at minute zero = 0,15,30,45
    • 3/20 = every 20th minute of the hour, starting at minute three = 3,23,43
    • /40 = every 40th minute of the hour= 40
    • 3/40 = every 40th minute of the hour, starting at minute three= 43

    Coming back to your question, the use of both operators gets the following result:

    */5 = every 5 minutes starting anytime. This way, it will start whenever changes the minute and repeat after 5 minutes, 10, etc.

    0/5 = every 5 minutes starting on minute 0. It will be internally considered as: 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 as these are the minutes that suit the condition +5 minutes coming from start at minute 0.


    Some references:

    这篇关于这些cron表达式是否等同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆