不喜欢广告? 无广告 今天

停止搜索Cron语法——那里有一个生成器

更新于

Cron表达式是那些你经常使用但总是记不住的东西之一。这里解释了五个字段的实际含义、容易让人出错的地方,以及为什么使用在线Cron表达式生成器是更聪明的选择。

Stop Googling Cron Syntax — There's a Generator for That 1
广告 移除?

It’s 2am. A deployment is scheduled for 6am. You need to double-check that the cron job will actually fire at the right time. So you open a new tab and type “cron syntax” into Google. Again.

This is a rite of passage. Every developer who has ever touched a Linux server has done it at least once — and most of us have done it more times than we care to admit. Cron expressions are one of those things you use constantly but never quite retain. The syntax sits in an uncomfortable zone between “too simple to look up” and “just specific enough to get wrong.”

There’s a better way. Use a cron expression generator online and let the tool handle the syntax while you focus on what actually matters.

Why Cron Syntax Refuses to Stick

Cron has five fields. Five. That’s it. And yet the order trips people up every single time:

# ┌───────────── minute (0–59)
# │ ┌───────────── hour (0–23)
# │ │ ┌───────────── day of month (1–31)
# │ │ │ ┌───────────── month (1–12)
# │ │ │ │ ┌───────────── day of week (0–6, Sunday=0)
# │ │ │ │ │
  * * * * * command

The problem isn’t that it’s hard — it’s that there are just enough special characters to introduce ambiguity. Is */5 “every 5 minutes” or “at minute 5”? Does 0 9 * * 1-5 run at 9am or 9pm? What happens if you forget that months are 1-indexed but weekdays start at 0?

These aren’t gotchas for beginners. They’re gotchas for everyone. A misconfigured cron job is one of the quieter ways to introduce a production incident — the kind where nothing crashes immediately, it just silently doesn’t run, and you only notice three days later.

The Five Fields, Explained Without Ceremony

Here’s the practical version:

  • Minute (0–59) — The minute of the hour when the job runs. 30 means the 30-minute mark. */15 means every 15 minutes.
  • Hour (0–23) — Uses 24-hour time. 9 is 9am. 17 is 5pm. No AM/PM nonsense.
  • Day of month (1–31) — Which calendar day. 1 is the first of the month. 15 is the 15th.
  • Month (1–12) — January is 1, December is 12. You can also use names: JAN, FEB, etc.
  • Day of week (0–6 or 1–7) — Sunday can be 07 depending on your cron implementation. Monday is always 1. This is the field that causes the most confusion.

The Special Characters That Matter

  • * — Every possible value (every minute, every hour, etc.)
  • */n — Every th interval. */5 in the minute field means every 5 minutes.
  • a-b — A range. 1-5 in the weekday field means Monday through Friday.
  • a,b,c — A list. 1,3,5 means Monday, Wednesday, Friday.
  • @reboot, @hourly, @daily — Shorthand aliases. Not supported everywhere.

Common Mistakes That Bite People

1. Forgetting Timezone

Cron runs in the server’s local timezone. If your server is UTC and you’re in New York, 0 9 * * * does not run at 9am Eastern — it runs at 4am or 5am, depending on DST. Always know your server timezone. Always.

2. Using Both Day-of-Month and Day-of-Week

If you specify a value in both the day-of-month day-of-week fields (instead of * in one of them), most cron implementations treat it as an OR — the job runs when either condition matches. That’s almost never what you want.

3. Expecting */1 to Mean “Once”

*/1 is the same as *. It means “every.” There is no way to express “run once” in standard cron — for that, you’d use at or a one-shot systemd timer.

4. Not Testing Before Deploying

Cron gives you no immediate feedback. You write the expression, save the crontab, and then wait. If it’s wrong, you find out at 3am when the scheduled backup doesn’t run. This is why using a cron next run calculator before you deploy is worth the 30 seconds it takes.

Use a Cron Expression Generator Instead

The honest advice: stop trying to hand-write cron expressions from memory. Use a generator. It’s not a sign of weakness — it’s how you avoid dumb mistakes in production.

cron expression generator on IOTools lets you build any expression visually — pick your minute interval, hour, day of week, and it shows you the exact expression and a plain-English explanation of when it runs. No memorization required, no documentation tabs open.

Once you have an expression, run it through the cron next run calculator. Paste the expression, get back the next 5–10 scheduled execution times. It takes five seconds and will tell you immediately if you’ve accidentally scheduled your cleanup job to run every minute instead of once a day.

That second check is the one most people skip. Don’t skip it.

Quick Reference: Expressions You’ll Actually Use

Expression意义
* * * * *每分钟
0 * * * *Every hour, on the hour
0 9 * * *Every day at 9:00am
0 9 * * 1-5Weekdays at 9:00am
*/15 * * * *每15分钟
0 0 * * 0Every Sunday at midnight
0 0 1 * *First day of every month at midnight
30 4 1,15 * *1st and 15th of the month at 4:30am
0 22 * * 1-5Weekdays at 10:00pm
@dailyOnce per day at midnight (shorthand)
想要享受无广告的体验吗? 立即无广告

安装我们的扩展

将 IO 工具添加到您最喜欢的浏览器,以便即时访问和更快地搜索

添加 Chrome 扩展程序 添加 边缘延伸 添加 Firefox 扩展 添加 Opera 扩展

记分板已到达!

记分板 是一种有趣的跟踪您游戏的方式,所有数据都存储在您的浏览器中。更多功能即将推出!

广告 移除?
广告 移除?
广告 移除?

新闻角 包含技术亮点

参与其中

帮助我们继续提供有价值的免费工具

给我买杯咖啡
广告 移除?