算清 cron 表达式到底什么时候运行
把五段 cron 表达式换算成接下来若干次运行时间,按你自己的时区,并正确处理「日」与「周」字段之间的 OR 语义。
不需要文件。请选择你的调度器实际使用的时区偏移。
在本标签页内运行,不上传任何内容。
结果
免费档:不需要文件,每次 1 个输入,每天 10 次。这件工具单件买断 $24,一次付款。对比价格。
授权:免费档。
这页与别处不同之处
多数 cron 问题不是语法写错,而是「日」和「周」同时被限定时究竟算 AND 还是 OR——规范答案是 OR,但不少实现悄悄按 AND 算。这个页面按规范做屏障式跳进求解,逐次给出真实触发时间,并把时区偏移作为参数而不是靠猜。
按规范实现「日/周」的 OR 语义,并直接给出该时区下的具体时间点。
示例输入与输出
| 环节 | 情形 | 体积 | 说明 |
|---|---|---|---|
| 输入 | 一条 cron 表达式 | 19 B | 0 9 * * 1-5 — weekday mornings, with no timezone stated anywhere |
| 输出 | 接下来十次运行的文本 | 470 B | dates and weekday names resolved against a UTC+8 offset, about 47 bytes per line |
这里写的是本页构建时对照的演示数字,不是对每个文件的承诺。
你可以自己核对什么
| 承诺 | 测试结果 |
|---|---|
| 列出的每次运行都落在表达式要求的分钟上。 | “*/15 9-17 * * 1-5”在 UTC+08:00 下只出现 :00、:15、:30、:45,时间在 09:00 到 17:45 之间,且只列工作日。 |
| 时区偏移被真的应用,而不是忽略。 | 输出把每个时间戳标为 UTC+08:00 并相应平移小时,09:00 是本地窗口起点,不是 01:00。 |
常见问题
以下问答目前仍为英文原文。
Why does a schedule matching both the 13th and Fridays fire on days that only satisfy one?
Because that is the classic cron behaviour: when both day fields are restricted, either may match. Many people expect an AND, which is why "the job ran on a day it should not have" is such a common incident. This page implements the OR, and says so.
Which timezone are the results in?
Whichever offset you enter, starting from the browser local time as the default. Servers running cron usually use their own local time, which is the single most common source of a job that never fires when expected.
What syntax is supported?
Stars, numbers, lists, ranges and steps, in the standard five fields: minute, hour, day of month, month, day of week. Both 0 and 7 mean Sunday.
What about seconds, or @daily style shortcuts?
Not supported, deliberately. Six-field cron with seconds exists in some schedulers and means something different from five-field cron; guessing which one you meant is worse than refusing.
What happens if the expression can never fire?
The page says so. February 31st never arrives, and a tool that silently returns nothing would leave you debugging a job that was never schedulable.
价格
这件工具一次性 $24,只要工具还在就一直可用。一次付款,不是订阅。授权存在当前浏览器里,凭交易号可在别处恢复。
免费档:每天 10 次。买断:不限每天次数。其余不变——这页每次只处理一个输入。