Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
每隔一个小时在15、55和35的位置进行cron_Cron - Fatal编程技术网

每隔一个小时在15、55和35的位置进行cron

每隔一个小时在15、55和35的位置进行cron,cron,Cron,首先,这些cron是否相似?如果相似,哪些是冗余的 a) 15,35,55 * * * * b) 15,35,55 */1 * * * c) 15,35,55 0/1 * * * 以35分钟和15分钟/55分钟的速度运行的cron是多少,以一小时为单位交换 e、 g 如果您想知道您的cron正在做什么,那么可以轻松地使用来验证 关于你的第一个问题,是的,这三个例子是相同的。手册规定如下: man 5 crontab:阶跃值可与范围一起使用。在带有/的范围之后指定 数字在整个范围内的值。例如

首先,这些cron是否相似?如果相似,哪些是冗余的

a) 15,35,55 *   * * *
b) 15,35,55 */1 * * *
c) 15,35,55 0/1 * * *
以35分钟和15分钟/55分钟的速度运行的cron是多少,以一小时为单位交换

e、 g


如果您想知道您的cron正在做什么,那么可以轻松地使用来验证

关于你的第一个问题,是的,这三个例子是相同的。手册规定如下:

man 5 crontab
阶跃值可与范围一起使用。在带有
/
的范围之后指定 数字在整个范围内的值。例如,可以使用
0-23/2
在“小时”字段中,指定每隔一小时执行一次命令 (V7标准中的备选方案为:
0,2,4,6,8,10,12,14,16,18,20,22
)。阶跃值也是允许的 星号之后,因此如果指定每两小时运行一次作业, 您可以使用
*/2

请参见以下示例:

# Example of job definition:
# .-------------------------- minute (0 - 59)
# |        .----------------- hour (0 - 23)
# |        |      .---------- day of month (1 - 31)
# |        |      |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |        |      |  |  .---- day of week (0 - 6) (Sunday=0 or 7)
# |        |      |  |  |
# *        *      *  *  *   command to be executed
  15,35,55 *      *  *  *   command1
  15,35,55 */1    *  *  *   command2
  15,35,55 0/1    *  *  *   command3
  15,35,55 0-23/1 *  *  *   command4
因此,在上面的示例中,
命令[1-4]
将同时执行,每小时执行一次,时间分别为15、35和55分钟

对于第二个问题,最好这样做:

# Example of job definition:
# .------------------------ minute (0 - 59)
# |      .----------------- hour (0 - 23)
# |      |      .---------- day of month (1 - 31)
# |      |      |  .------- month (1 - 12) OR jan,feb,mar,apr .   
# |      |      |  |  .---- day of week (0 - 6) (Sunday=0 or 7)
# |      |      |  |  |
# *      *      *  *  *   command to be executed
  15    0/2     *  *  *   command1
  35,55 1/2     *  *  *   command1
  15    8/2     *  *  *   command2
  35,55 9/2     *  *  *   command2
  15    8-18/2  *  *  *   command3
  35,55 9-18/2  *  *  *   command3

这里,
command1
将在
{00,02,04,06,…,22}:15
{01,03,05,…,23}:{35,15}
command2
将在
{08,10,…,22}:15
{09,11,…,23}:{35,15}和
command3
将在
{08,10,…,18:15和
<09,17}执行

关于第二个问题,你的意思是我不会把时间表放在一个cron上?我最好安排两次
command1
命令?@legen---waitforit---dary是的,我只是根据你的需要给出了3个选项
# Example of job definition:
# .------------------------ minute (0 - 59)
# |      .----------------- hour (0 - 23)
# |      |      .---------- day of month (1 - 31)
# |      |      |  .------- month (1 - 12) OR jan,feb,mar,apr .   
# |      |      |  |  .---- day of week (0 - 6) (Sunday=0 or 7)
# |      |      |  |  |
# *      *      *  *  *   command to be executed
  15    0/2     *  *  *   command1
  35,55 1/2     *  *  *   command1
  15    8/2     *  *  *   command2
  35,55 9/2     *  *  *   command2
  15    8-18/2  *  *  *   command3
  35,55 9-18/2  *  *  *   command3