cron-parser
Read, write, and debug cron expressions with field reference, scheduling logic, and common patterns.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- cron-parser
- category
- utilities
- description
- Read, write, and debug cron expressions with field reference, scheduling logic, and common patterns.
03 SKILL.md 正文
Overview
Cron expressions are write-only for most people — everyone copies them, few can read them. But misreading a schedule means backups that never run or jobs that fire 60x too often. This skill makes cron legible: the five fields, special strings, the day-of-month/day-of-week gotcha, and debugging techniques for "why didn't it run?"
When to use
-
Writing cron schedules for jobs and automation
-
Reading and understanding existing cron expressions
-
Debugging jobs that run at wrong times (or not at all)
-
Choosing between cron and modern schedulers
-
Documenting schedules for teams
Core concepts
-
- The five fields.
minute hour day-of-month month day-of-week— in that order.30 2 * * *= 2:30 AM daily. Memorize the order with: "my happy dog makes dinner" (minute, hour, dom, month, dow) or just drill it until it's reflex.
- The five fields.
-
- Field syntax.
*(every),*/15(every 15),1,15(list),1-5(range, Mon-Fri for dow),9-17/2(every 2 hours 9-5). Ranges and steps compose; lists don't take steps in classic cron.
- Field syntax.
-
- The DOM/DOW trap. When both day-of-month and day-of-week are restricted (not
*), cron runs when EITHER matches — not both.0 0 1 * 1runs on the 1st of the month AND every Monday. This surprises everyone once.
- The DOM/DOW trap. When both day-of-month and day-of-week are restricted (not
-
- Special strings.
@reboot,@yearly,@monthly,@weekly,@daily,@hourly— readable shorthands. Note:@rebootbehavior varies (and doesn't exist in all cron implementations).
- Special strings.
-
- Environment minimalism. Cron runs with a sparse environment: minimal PATH, no shell profile. The #1 "works manually, fails in cron" cause is PATH — use absolute paths for everything or set PATH explicitly in the crontab.
-
- Cron flavors differ. Vixie cron (classic Linux), cronie, systemd timers (the modern Linux
alternative — more features, logging built in), and cloud schedulers (CloudWatch Events, Cloud
Scheduler) all have quirks.
@reboot, seconds fields, and timezone handling vary — check your implementation.
- Cron flavors differ. Vixie cron (classic Linux), cronie, systemd timers (the modern Linux
alternative — more features, logging built in), and cloud schedulers (CloudWatch Events, Cloud
Scheduler) all have quirks.
Practical workflow
-
- Write it plainly first. "Every weekday at 9:30 AM" → then translate:
30 9 * * 1-5. Describe in words before encoding — the words are the spec you'll verify against.
- Write it plainly first. "Every weekday at 9:30 AM" → then translate:
-
Use the field table. Build expressions field by field:
-
minute (0-59), hour (0-23), dom (1-31), month (1-12), dow (0-7, both 0 and 7 = Sunday)
-
Verify each field independently before combining.
-
-
Common patterns (verify against your cron flavor):
-
*/5 * * * *— every 5 minutes -
0 * * * *— hourly -
0 2 * * *— daily 2 AM -
0 9 * * 1— Mondays 9 AM -
0 0 1 * *— first of month midnight -
30 9 * * 1-5— weekdays 9:30 AM -
0 0 * * 0— Sundays midnight
-
-
- Debug non-running jobs. Checklist: is the cron daemon running? Is the crontab installed
for the right user (
crontab -l)? Absolute paths everywhere? Environment variables set? Permissions on the script (executable)? Output captured (redirect stdout/stderr to a log — silent failures are cron's default)? Timezone correct (system vs expected)?
- Debug non-running jobs. Checklist: is the cron daemon running? Is the crontab installed
for the right user (
-
- Log everything.
30 2 * * * /opt/job.sh >> /var/log/job.log 2>&1— without output capture, failures vanish. Better: have the job log itself with timestamps.
- Log everything.
-
- Consider alternatives. Need seconds precision, dependencies, retries, or observability? Cron is the wrong tool — use systemd timers, or a proper scheduler (Airflow/Temporal for workflows, cloud schedulers for cloud). Cron is for simple, independent, minute-granularity jobs.
Common pitfalls
-
- The DOM/DOW OR trap.
0 0 1 * 1doesn't mean "first Monday" — it means "1st AND Mondays." For "first Monday," you need wrapper logic in the script.
- The DOM/DOW OR trap.
-
- Timezone confusion. Cron uses system local time (usually). DST transitions cause skipped or
doubled runs. For UTC-critical jobs, set
CRON_TZ(where supported) or run the system in UTC.
- Timezone confusion. Cron uses system local time (usually). DST transitions cause skipped or
doubled runs. For UTC-critical jobs, set
-
- Environment assumptions.
pythonresolving via PATH,~expansion, locale settings — all differ under cron. Absolute paths, explicit env vars, tested in a clean shell.
- Environment assumptions.
-
- Overlapping runs. A job that takes 70 minutes on an hourly schedule stacks up. Use file
locks (
flock) to prevent concurrent runs.
- Overlapping runs. A job that takes 70 minutes on an hourly schedule stacks up. Use file
locks (
-
- Silent failures. No output redirection = no evidence. Every cron job should log somewhere you'll actually check — or alert on failure.
-
- Editing the wrong crontab. User crontab vs system
/etc/crontab(which has an extra user field) vs/etc/cron.d/. The 6-field system format in a 5-field user crontab breaks mysteriously.
- Editing the wrong crontab. User crontab vs system
04 同仓库更多 Skills
web-scrape
Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.
design-taste-frontend
tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).