指定“所有奇数值”在crontab? [英] Specifying "all odd values" in crontab?

查看:221
本文介绍了指定“所有奇数值”在crontab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在crontab中,我可以使用星号来表示每个值,或者* / 2表示每个偶数值。



值? (像1 + * / 2这样的工作?)

解决方案

根据您的cron版本, (小时):

  1-23 / 2 

通过crontab(5)联机帮助页中的EXTENSIONS部分:

 范围可以包括steps,因此1-9 / 2与1,3,5,7,9相同。 

对于更便携的解决方案,我怀疑你只需要使用简单的列表:

  1,3,5,7,9,11,13,15,17,19,21,23 

但是它可能更容易将你的命令包装在shell脚本中,如果它不是在一个奇怪的分钟被调用, p>

In crontab, I can use an asterisk to mean every value, or "*/2" to mean every even value.

Is there a way to specify every odd value? (Would something like "1+*/2" work?)

解决方案

Depending on your version of cron, you should be able to do (for hours, say):

   1-23/2

Going by the EXTENSIONS section in the crontab(5) manpage:

   Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".

For a more portable solution, I suspect you just have to use the simple list:

   1,3,5,7,9,11,13,15,17,19,21,23

But it might be easier to wrap your command in a shell script that will immediately exit if it's not called in an odd minute.

这篇关于指定“所有奇数值”在crontab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆