crontab(5) 定义了以下字段:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
Run Code Online (Sandbox Code Playgroud)
并解释说:
Run Code Online (Sandbox Code Playgroud)Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22'').
所以,就我的理解而言,没有双周刊。我很确定有解决方法,你的是什么?还是我错过了什么?
许多 cron(您没有指定您使用的是哪个)支持范围。所以像
0 0 1-7,15-21 * 3
Run Code Online (Sandbox Code Playgroud)
将达到本月的第一个和第三个星期三。
注意:不要将它与vixie cron(包含在 RedHat 和 SLES 发行版中)一起使用,因为它在月份和星期几字段之间使用or代替and。
您可以在每个星期三让 cron 运行该事物,然后让该事物运行来决定它是偶数周还是奇数周。例如:
#!/bin/bash
week=$(date +%U)
if [ $(($week % 2)) == 0 ]; then
echo even week
else
echo odd week
fi
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
37149 次 |
最近记录: |