🛠️ToolsShed

Cron式パーサー

Cron式を解析して次回実行時刻を表示します。

Quick Presets

Format: minute hour day-of-month month day-of-week

Cronパーサーは、Cron式をわかりやすい英語の説明に変換し、次の数回のスケジュールされた実行時間を表示します。Cronは、Unix/Linuxシステム、CI/CDパイプライン、サーバーレス関数、クラウドスケジューラで繰り返しタスクを定義するために使用される標準的なジョブスケジューリング構文です。

標準の5フィールドまたは拡張6フィールド形式のCron式を入力すると、ツールは即座に人間が読める言語でその意味を説明し、今後の実行時間を一覧表示します。ビジュアルビルダーを使用して、ドロップダウンから分、時、日、月を選択して式を作成することもできます。

Cron構文の理解は、スケジュールされたバックアップ、定期的なデータベースのクリーンアップ、自動レポート、レート制限されたAPIポーリングなどのタスクに不可欠です。

よくある質問

コード実装

from croniter import croniter
from datetime import datetime

# Parse and get next execution times
cron_expr = "0 9 * * 1-5"  # 9 AM every weekday
base = datetime.now()
cron = croniter(cron_expr, base)

print("Next 5 execution times:")
for _ in range(5):
    print(cron.get_next(datetime))

# Check if an expression is valid
def is_valid_cron(expr):
    try:
        croniter(expr)
        return True
    except (ValueError, KeyError):
        return False

print(is_valid_cron("*/15 * * * *"))  # True
print(is_valid_cron("60 * * * *"))    # False

# Get previous execution time
cron2 = croniter("0 0 * * *", base)
print("Last midnight:", cron2.get_prev(datetime))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.