Linux corntab 表达式, 我百思不得其解, 求助各位 / \

cheng_sukai · August 05, 2022 · Last by cheng_sukai replied at August 06, 2022 · 543 hits

cron 在线计算器:https://tool.lu/crontab/

cron 表达式:0 0 */3 9 0

注 : 上面的意思是从 9 月份开始,每隔 3 天执行一次,但是为什么 10 号和 11 号会连续执行,百思不得其解,我很苦恼 / \

https://crontab.guru/#0_0_*/3_9_0

“At 00:00 on every 3rd day-of-month if it's on Sunday in September.”

next at 2022-09-04 00:00:00
then at 2022-09-25 00:00:00
then at 2023-09-10 00:00:00
then at 2024-09-01 00:00:00
then at 2024-09-22 00:00:00

谢谢,为什么 9/11 和 9/18 都不行呢?

Reply to hellorails

谢谢,为什么 9/11 和 9/18 都不行呢?

cron 表达式:0 0 */3 9 0 应该是默认周日会执行,你可以换成 7 月份、8 月份、10 月份试下。

Reply to cheng_sukai

看描述,应该是每 3 周,9/11 和 9/18 不就是每周了吗

Reply to hellorails

希望这样子做,但是 crontab 看上去无法实现

太过复杂的计划任务我一般都是在程序代码里面多加一层逻辑判断是否执行

“At 00:00 on every 3rd day-of-month if it's on Sunday in September.”不是写的很清楚吗,依赖了周日,不要周日的话把最后一个改星号

另外一楼的工具和 crontab.guru 的结果不一样,我更信 crontab.guru 的

Reply to mizuhashi

好的,我还是没搞定,哭了

You need to Sign in before reply, if you don't have an account, please Sign up first.