From 29aedb29d312e5e0aee2ed7204e589dc56ea0f12 Mon Sep 17 00:00:00 2001 From: NeonCodex Agent Date: Wed, 9 Sep 2026 14:39:28 +0000 Subject: [PATCH] NeonCodex Agent: test cron schedule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Everything is working perfectly! Here's a full summary of what was set up and the results: --- ## ✅ Cron Schedule Tester — Results A Python-based cron testing script was created at `/workspace/test_cron.py` using the **`croniter`** library. It tested **7 common cron expressions** and for each one it: - ✅ **Validated** the expression - 📋 **Broke down** each field (Minute / Hour / Day / Month / Weekday) - 🕐 Listed the **next 5 upcoming runs** - 🕐 Listed the **last 5 previous runs** --- ### 📌 Expressions Tested | Expression | Description | Result | |---|---|---| | `* * * * *` | Every minute | ✅ Valid | | `*/15 * * * *` | Every 15 minutes | ✅ Valid | | `0 9 * * 1-5` | 9 AM on weekdays | ✅ Valid | | `0 0 1 * *` | Midnight on 1st of every month | ✅ Valid | | `30 6 * * 0` | 6:30 AM every Sunday | ✅ Valid | | `0 */6 * * *` | Every 6 hours | ✅ Valid | | `0 8-18 * * 1-5` | Every hour 8 AM–6 PM on weekdays | ✅ Valid | --- ### 💡 How to Test YOUR Cron Expression Please share your cron expression and I'll test it! For example: ``` 0 3 * * 1 → 3 AM every Monday */5 9-17 * * 1-5 → Every 5 min during business hours 0 0 15 * * → Midnight on the 15th of every month ``` **Just provide your cron expression** and I'll validate it, explain it, and show you exactly when it will fire! 🎯 --- test_cron.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test_cron.py diff --git a/test_cron.py b/test_cron.py new file mode 100644 index 0000000..9c6eceb --- /dev/null +++ b/test_cron.py @@ -0,0 +1,58 @@ +from croniter import croniter, CroniterBadCronError +from datetime import datetime, timezone +import sys + +def test_cron(expression: str, count: int = 10, start_time: datetime = None): + print(f"\n{'='*55}") + print(f" Cron Expression: '{expression}'") + print(f"{'='*55}") + + # Validate + if not croniter.is_valid(expression): + print(" ❌ INVALID cron expression!") + return + + print(" ✅ Expression is VALID\n") + + # Describe frequency + parts = expression.split() + labels = ["Minute", "Hour", "Day(month)", "Month", "Day(week)"] + print(" 📋 Field Breakdown:") + for label, part in zip(labels, parts): + print(f" {label:<12}: {part}") + + # Next N occurrences + start = start_time or datetime.now() + cron = croniter(expression, start) + print(f"\n 🕐 Next {count} scheduled runs (from {start.strftime('%Y-%m-%d %H:%M:%S')}):") + for i in range(count): + next_run = cron.get_next(datetime) + print(f" {i+1:>2}. {next_run.strftime('%Y-%m-%d %H:%M:%S')} ({next_run.strftime('%A')})") + + # Previous N occurrences + cron_prev = croniter(expression, start) + print(f"\n 🕐 Last {count} scheduled runs (before {start.strftime('%Y-%m-%d %H:%M:%S')}):") + prev_runs = [cron_prev.get_prev(datetime) for _ in range(count)] + for i, run in enumerate(prev_runs): + print(f" {i+1:>2}. {run.strftime('%Y-%m-%d %H:%M:%S')} ({run.strftime('%A')})") + + print() + +# ── Demo: test several common expressions ────────────────────── +examples = [ + ("* * * * *", "Every minute"), + ("*/15 * * * *", "Every 15 minutes"), + ("0 9 * * 1-5", "9 AM on weekdays"), + ("0 0 1 * *", "Midnight on 1st of every month"), + ("30 6 * * 0", "6:30 AM every Sunday"), + ("0 */6 * * *", "Every 6 hours"), + ("0 8-18 * * 1-5", "Every hour 8 AM–6 PM on weekdays"), +] + +print("\n🔍 CRON SCHEDULE TESTER") +print("Testing common cron expressions...\n") + +for expr, description in examples: + print(f" 📌 {description}") + test_cron(expr, count=5) +