Monu Tools

Cron 表达式生成器

构建并检查 cron 表达式。选择预设或编辑五个字段,并查看你时区的下次运行时间。完全在你的浏览器中运行。

如何使用 Cron 生成器

  1. 01

    选择预设,或在五个字段中输入 cron 表达式。

  2. 02

    编辑时查看每个带标签并经过校验的字段。

  3. 03

    查看按你本地时区计算的下次运行时间。

What a cron expression is

A cron expression is a compact string of five fields that tells a scheduler when to run a task: minute, hour, day of month, month and day of week. It is powerful but easy to get wrong, and a misplaced asterisk can mean a job fires every minute instead of once a day.

How the generator helps

Start from a common preset (every hour, every day at midnight, every Monday at 9 AM) or build a custom expression field by field, with each field labeled and validated as you type.

Crucially, it previews the next five run times in your browser's local time zone, so you can confirm the schedule actually does what you intended before you deploy it.

Field syntax and values

Each field accepts more than a single value: an asterisk means every value, a list like MON,WED,FRI picks several, a range like MON-FRI spans days, and a step like */15 in the minute field runs at 0, 15, 30 and 45 past the hour.

The output works with standard cron on Linux and macOS, crontab, AWS EventBridge, GitHub Actions schedules and most job-scheduling libraries.

Gotchas to watch for

One classic trap is setting both day-of-month and day-of-week: standard cron then runs when either matches, not both, so a job can fire more often than expected. Leaving one of the two as an asterisk avoids the surprise.

This tool targets standard five-field cron, so platform extensions like a seconds field or @reboot are not produced here. Remember too that the job runs in the executing server's time zone, which may differ from the local preview.

常见问题

五个字段是什么意思?

依次为:分钟、小时、月内日期、月份和星期。星号表示每个值,因此 * * * * * 每分钟运行一次。

如何让任务每 15 分钟运行一次?

在分钟字段使用步长值:*/15 * * * * 在每小时的第 0、15、30 和 45 分钟运行。

星期字段接受什么?

数字 0 到 6(星期日为 0,7 也表示星期日)或像 MON 这样的三字母名称。你可以使用范围(MON-FRI)和列表(MON,WED,FRI)。

为什么它匹配的天数比我预期的多?

当月内日期和星期都被设置时,标准 cron 会在任一匹配时运行,而非两者都匹配。将其中一个保留为 * 可避免意外。

它支持秒或非标准语法吗?

本生成器面向标准的五字段 cron。某些平台增加了秒字段或 @reboot 等扩展,这里不会生成。

运行时间是哪个时区?

预览显示你浏览器本地时区的下次运行时间。执行任务的服务器使用它自己的时区,因此请确认两者一致。

来源

嵌入此工具

将此工具添加到你自己的网站。复制下方代码片段即可,它会自动保持最新。

<iframe src="https://monu.tools/embed/zh/cron-generator" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>

相关工具