AIX 7.1 中错误时间的 Cron 作业 运行

Cron job run at the wrong time in AIX 7.1

我已将我的 cronjob 配置为 运行 在每个月的第一个星期一 8:40am 如下

40 08 1-7 * 1 /fs/test/testtime.sh

但它不仅 运行 星期一,而且 运行 今天星期二。

有什么我遗漏的吗?

来自 crontab 的手册页(我的重点):

Note: The day of a command's execution can be specified by two fields - day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time.

For example, 30 4 1,15 * 5 would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

因此,在您的情况下,每个月的前 7 天中的每一天 运行 工作,每周一 加上

您可以通过在命令中添加 AND 条件而不是依赖时间规范中的 OR 条件来执行您希望的操作,例如:

40 08 1-7 * * test $(date +\%u) -eq 1 && /fs/test/testtime.sh

这将 运行 所有 那些天(每个月的前 7 天)的实际 cron 作业,但 有效负载 (脚本)只有在周一时才会 运行。