cron任务的小时部分是6,10-12有效的语法吗?

我知道“10-12”是chron小时部分的有效范围,“6,7,8”也是avlid语法。

如果有效小时数在6和10到12之间,我可以将这两个“6,10-12”结合起来吗?

这取决于哪个cron守护进程正在使用中。

Debian / Ubuntu默认使用Vixie cron。 它的手册页( man 5 crontab )有这样的说法:

 Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11. 

并进一步…

 Lists are allowed. A list is a set of numbers (or ranges) separated by commas. 

所以对于这个特定的实现,“ 6,10-12 ”将是有效的,因为它是包含数字和范围的列表,并且范围可以包括列表。

如果你不确定, man 5 crontab应该清晰。