How to create cron statement to run for multiple hours

后端 未结 2 735
广开言路
广开言路 2020-12-29 02:24

I need a cron statement to run for few hours eg 1-8 then 10-15. In this case will the following statement work,

0 1-8,10-15 * * * 

If not

相关标签:
2条回答
  • 2020-12-29 02:58

    I find it more readable to have two crontab entries:

    0 1-8 * * * ...
    0 10-15 * * * ...
    
    0 讨论(0)
  • 2020-12-29 03:02

    You cannot, you can use either multiple values OR a range

    0 1,2,3,4,5,6,7,8,10,11,12,13,14,15 * * *

    Source:

    Time tags are separated by spaces. Do not use spaces within a tag, this will confuse cron. All five tags must be present. They are a logical AND of each other. There is another space between the last time tag and the first command.

    A time tag can be a wildcard "*", which means "all". It can be one value, several values, a range, or a fractional range.

    0 讨论(0)
提交回复
热议问题