🤖 The AI Prompt That Catches a Cron Schedule Before It Quietly Never Fires
A cron expression is deceptively easy to get subtly wrong – an off-by-one hour field, a day-of-month value that doesn’t exist in every month, an assumption about day-of-week logic that most implementations actually OR together instead of AND. None of those mistakes produce an error anywhere; the job is simply scheduled, and it either runs at the wrong time or, in the worst case, never runs at all. This prompt asks an AI assistant to walk through a cron expression field by field and specifically hunt for that category of silent scheduling mistake.
📋 The Prompt
Here's a cron expression (or several) from our deployment config: [PASTE CRON EXPRESSION(S) HERE, e.g. "0 0 30 2 *"] For each one: 1. Explain in plain English exactly when it fires (translate every field, don't just restate the raw expression back to me) 2. Check specifically for day-of-month values that some months don't have (a 30th or 31st on a schedule meant to run monthly), and for any date that only exists in some years (February 29th) 3. Flag any ambiguity between the day-of-month and day-of-week fields - most cron implementations treat these as OR'd together when both are restricted, which catches people off guard 4. State clearly whether the expression assumes server-local time or UTC, and ask me to confirm which one this specific system actually uses List every schedule that will fire less often than intended, more often than intended, or never at all, with the specific reason why.
✅ Why This Prompt Works
- Asking for a plain-English translation rather than a restatement of the raw expression forces an actual walk-through of each field, which is where a subtly wrong value (an hour field that’s off by one, a day that doesn’t exist in every month) tends to surface.
- Explicitly asking about the day-of-month and day-of-week OR behavior targets one of the single most common sources of a cron schedule firing on unintended days, since most people reasonably assume the two fields combine with AND logic instead.
- Asking the model to flag anything that fires ‘never’, not just ‘incorrectly’, catches the most expensive mistake of all – a schedule that looks like it should run monthly or yearly but references a date combination that silently never occurs.
⚠️ Where to Draw the Line
- This reasons about the cron expression’s own syntax and standard cron semantics – it has no way to know about implementation-specific quirks in whichever scheduler actually runs it (a particular library’s nonstandard field support, for instance), so confirming against that system’s own documentation still matters for anything unusual.
- Confirming the actual timezone the scheduler runs in is something only you can answer definitively – the prompt can flag that the question matters and needs answering, but it can’t look up your server’s configured timezone for you.
A cron expression that compiles without error isn’t the same as one that actually fires when you think it does – and the gap between those two is exactly where this prompt spends its time.
