Cron 表达式生成器

轻松生成每小时、每天、每周和每月运行的 crontab 表达式。

// about

工具介绍

Cron 使用五个字段来描述 Linux 命令何时运行。本生成器可将常见的重复周期选项转换为可直接复制的表达式。

如何使用

  1. 选择任务的重复频率。
  2. 设置该周期所显示的时间和日期值。
  3. 复制生成的表达式,并放在 shell 命令之前。

人们为何使用此工具

  • 无需记忆复杂的 cron 语法。
  • 生成标准的五字段 Linux crontab 表达式。
  • 可将结果直接复制到 crontab 文件或部署脚本中。
指南 · 日期与时间 · 约 3 分钟

Unix 时间戳详解:秒与毫秒、时区和 2038 年问题

1700000000 是什么时候?为什么有些系统用 13 位数字?为什么时间恰好差了 8 个小时?弄懂几个概念,大部分时间相关的 bug 就会消失。

Unix 时间戳(Unix 时间、纪元时间)是一个整数,表示自 1970 年 1 月 1 日 00:00:00 UTC(即 Unix 纪元)以来经过的秒数。0 是 1970-01-01 00:00:00 UTC,1700000000 是 2023-11-14 22:13:20 UTC。

0           → 1970-01-01 00:00:00 UTC
1700000000  → 2023-11-14 22:13:20 UTC
1735689600  → 2025-01-01 00:00:00 UTC
2147483647  → 2038-01-19 03:14:07 UTC
什么是 Unix 时间戳、如何区分 10 位和 13 位数值、UTC 与本地时间的换算、夏令时陷阱以及 2038 年问题。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "Cron 表达式生成器" that meets the requirements below.

## Goal

Build a tool that creates and explains standard five-field cron expressions from a chosen schedule.

## Core features

- Schedule picker (every N minutes, hourly, daily, weekly, monthly)
- Plain-language description of the expression
- Preview of the next five run times
- Time zone selection (UTC, Asia/Seoul, …)
- Parse an expression typed by the user

## Inputs

- Schedule type and minute/hour/weekday/day values
- Time zone

## Outputs

- Cron expression
- Description
- Next run times

## Edge cases and handling rules

- Warn that setting both day fields means OR
- Explain steps that do not divide evenly, such as */45
- Validate out-of-range values like minute 60
- Explain run-time differences on UTC servers

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- Daily at 02:00 gives '0 2 * * *'
- Weekdays at 09:30 give '30 9 * * 1-5'
- '*/15 * * * *' runs every 15 minutes

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-cron-generator/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-cron-generator
description: Use when building or changing a Cron 表达式生成器 tool. Build a tool that creates and explains standard five-field cron expressions from a chosen schedule.
---

# Build: Cron 表达式生成器

## Goal

Build a tool that creates and explains standard five-field cron expressions from a chosen schedule.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Schedule picker (every N minutes, hourly, daily, weekly, monthly)
- Plain-language description of the expression
- Preview of the next five run times
- Time zone selection (UTC, Asia/Seoul, …)
- Parse an expression typed by the user

## Inputs

- Schedule type and minute/hour/weekday/day values
- Time zone

## Outputs

- Cron expression
- Description
- Next run times

## Rules

- Warn that setting both day fields means OR
- Explain steps that do not divide evenly, such as */45
- Validate out-of-range values like minute 60
- Explain run-time differences on UTC servers
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] Daily at 02:00 gives '0 2 * * *'
- [ ] Weekdays at 09:30 give '30 9 * * 1-5'
- [ ] '*/15 * * * *' runs every 15 minutes

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。