我需要安排一个cron作业,每隔30分钟从0到6和从13到23安排运行。我试过这段代码:
cron { "MyJob":
ensure => present,
command => "my-cron-command",
user => 'root',
hour => "0-6,13-23",
minute => '*/30',
environment => "MY_ENV"
}
失败
0-6,13-23 is not a valid hour
我应该使用哪种hour
格式?我是否需要在cron子句中进行任何其他更改?
答案 0 :(得分:1)
应该只列出小时数:
cron { "MyJob":
ensure => present,
command => "my-cron-command",
user => 'root',
hour => [0,1,2,3,4,5,6,13,14,15,16,17,18,19,20,21,22,23],
minute => '*/30',
environment => "MY_ENV"
}
可以使用,但hour => "0-6,13-23"
没有。
答案 1 :(得分:1)
关闭,但没有雪茄。
cron { "MyJob":
ensure => present,
command => "my-cron-command",
user => 'root',
hour => [ "0-6", "13-23" ],
minute => '*/30',
environment => "MY_ENV"
}
答案 2 :(得分:1)
如果要为任何属性放置多个值。将它们放在数组列表中。那么,小时将是['0-6','13-23']