crontab小时范围a-b也会在b之后吗? [英] Will crontab hour range a-b run after b too?
问题描述
说我有一个crontab,它每隔 20
分钟运行一次,并且我有一个小时范围,该范围可以变化,所以可以说 ab
,在一个示例中可能看起来像
* / 20 5-23 * * * / usr / bin / cool_program
我的问题是,cron的运行时间是23:00、23:20、23:40和00也是:00吗?
GK27的答案不能完全回答问题,所以让我澄清一下:
<当时间与提供的表达式匹配时,p>
cron
将运行作业。当分钟被20( * / 20
)整除时,您的表达式告诉它运行,而当小时在指定范围内(包括 5-23
)。剩余的三个 *
告诉它与任何一天,任何月份和一周中的任何一天匹配。 因此第一个作业将在05:00运行,因为小时 05
在5到23之间,分钟在 00
被20整除。最后一个作业将在23:40运行,因为小时 23
在5到23之间,分钟在 40
可被20整除。由于小时 00
不在5范围内,因此它不会在00:00运行到23。
Say I have a crontab which runs every 20
minutes and I have a hour range which can vary so lets say a-b
, which in one example could look like
*/20 5-23 * * * /usr/bin/cool_program
My question is, will the cron run at 23:00, 23:20, 23:40 and 00:00 too?
GK27's answer does not fully answer the question, so let me clarify:
cron
will run jobs when the time matches the expression provided. Your expression tells it to run when the minute is divisible by 20 (*/20
) and your hour range tells it to run when the hour is within the specified range inclusively (5-23
). The remaining three *
tell it to match any day, month, and any day of the week.
Therefore the first job will run at 05:00 because the hour, 05
, is in the range 5 to 23 and the minute, 00
, is divisible by 20. The last job will run at 23:40 because the hour, 23
, is in the range 5 to 23 and the minute, 40
, is divisible by 20. It will not run at 00:00 because the hour, 00
, is not in the range 5 to 23.
这篇关于crontab小时范围a-b也会在b之后吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!