cron 式の解説・検証と次回実行時刻(タイムゾーン・夏時間対応)
Cron expression explainer with next runs, time zones and DST warnings
cron 式の意味をわかりやすく説明して誤りを見つけ、指定したタイムゾーンでの次回実行時刻を一覧にします。日付と曜日の OR 条件や夏時間の落とし穴も警告します。
できること
「この cron はいつ動くのか」「平日9時半に動かしたい」といった場面で、式の意味と実際の実行時刻を確かめます。
- 5フィールドの標準 cron、秒付き6フィールド(Spring・Quartz・node-cron 形式)、
@dailyなどのエイリアスに対応 - 各フィールドを展開した値と、英語での平易な説明を表示
- 指定したタイムゾーン(IANA 名または
+09:00のような固定オフセット)で、次の N 回の実行時刻を現地時刻と UTC で一覧 - 日付と曜日の両方を指定したときの OR 条件、
*/2のような星付きステップの扱い、31日がない月や2月29日、夏時間で消える時刻・2回来る時刻を警告 - 範囲外の値、逆順の範囲、Quartz 専用の
LW#などはエラーとして理由を表示
使い方
python scripts/cron_explain.py "*/15 9-17 * * MON-FRI" --tz Asia/Tokyo --count 10
python scripts/cron_explain.py "30 2 * * *" --tz America/New_York --from 2026-03-07T00:00
python scripts/cron_explain.py @weekly --json
Claude・Codex・Hermes Agent・Cursor に cron の意味や作成を頼むと、方言とタイムゾーンを確認したうえでこの手順で検証し、最終的な式と次回実行時刻を示します。
必要な環境
- Python 3.10 以上(標準ライブラリの zoneinfo を使用)
- Windows などでタイムゾーンが見つからない場合は
python -m pip install tzdataを実行するか、固定オフセットを指定します
注意点
- 式を解析して表示するだけで、crontab やスケジューラーの設定は変更しません。
- 夏時間の扱いや
5/15のような書き方の可否は cron の実装ごとに異なります。計算は Vixie cron / cronie の考え方に合わせ、違いがありうる点は警告で示します。 - Quartz の
LW#と7番目の年フィールドには対応していません。
English description
Explain and validate cron expressions, list the next run times in any time zone, and warn about the day-of-month/day-of-week OR rule and DST traps.
What it does
Check what a cron schedule really means and when it will actually run.
- Supports standard 5-field cron, 6-field with seconds (Spring, Quartz, node-cron style) and aliases such as
@daily - Shows each field's expanded values and a plain-English description
- Lists the next N runs in local time and UTC for any IANA time zone or a fixed offset such as
+09:00 - Warns about the day-of-month/day-of-week OR rule, star-step fields like
*/2, months without day 31, Feb 29, and DST gaps and repeated hours - Rejects out-of-range values, reversed ranges and Quartz-only
LW#with a clear reason
How to use
python scripts/cron_explain.py "*/15 9-17 * * MON-FRI" --tz Asia/Tokyo --count 10
python scripts/cron_explain.py "30 2 * * *" --tz America/New_York --from 2026-03-07T00:00
python scripts/cron_explain.py @weekly --json
Ask Claude, Codex, Hermes Agent or Cursor to explain or write a cron schedule; it confirms the dialect and time zone, verifies with the script, and delivers the final expression with its next runs.
Requirements
- Python 3.10+ (standard library
zoneinfo) - If a zone is not found (common on Windows), run
python -m pip install tzdataor pass a fixed offset
Caveats
- It only parses and prints; it never edits crontabs or scheduler settings.
- DST handling and syntax such as
5/15differ between implementations. Calculations follow Vixie cron / cronie, and possible differences are flagged as warnings. - Quartz
LW#and the 7th year field are not supported.
インストール方法
- ダウンロードしたZIPを展開します(中に
cron-expression-explainer/フォルダとSKILL.mdがあります)。 - フォルダごと、使うエージェントのスキル置き場にコピーします。
- Claude:
~/.claude/skills/(プロジェクト単位なら.claude/skills/) - Hermes Agent:
~/.hermes/skills/ - Codex:
~/.agents/skills//Cursor:~/.cursor/skills/ - Claude アプリ(claude.ai):「カスタマイズ → スキル」からZIPをアップロード
- Claude:
- エージェントを再起動し、スキル一覧に表示されることを確認します。
出品者
出品スキル 44 件