Test an AI cron line against times you already wrote down

Use five-field Debian cron. Write four clock times first. Keep the chat’s line only when every time matches.

Published 2026-11-23 · Translation: VI

In short

  • Name the scheduler: five-field user crontab in Debian cron. A sixth number is a different product.
  • Write four clock times before you read the reply: two should fire, two should not (include a wrong minute and a wrong weekday).
  • Keep the chat’s line only when your checker says yes on the fire times and no on the quiet times.

Example (made up): backup at 09:15 Monday–Friday → 15 9 * * 1-5. A chat can invent a cron line. You still check four clocks yourself.

Same habit as testing a regex or a unit conversion.

Five-field Debian cron → four times written first → every time matches → keep the line.

The clock is the daemon’s clock. A TZ= line in the file does not move the five fields.

Five fields and the day rule chats miss

From Debian crontab(5) (23 November 2026): minute, hour, day-of-month, month, day-of-week (0 and 7 = Sunday). *, ranges, lists, and / steps work as on that page.

Important: the command runs when minute, hour, and month match, and at least one day field matches. If both day-of-month and day-of-week are restricted (neither is *), Debian runs when either matches — e.g. 30 4 1,15 * 5 runs on the 1st, the 15th, and every Friday.

This page only treats a day field as “open” when it starts with *. So */2 counts as open. That is why 0 0 */2 * sun is narrower than a POSIX “OR” reading.

Checker used here: Python 3.12.3 (does not start cron). Weekdays from datetime. Six-field strings stop the function.

import datetime

DOW = {"sun": 0, "mon": 1, "tue": 2, "wed": 3, "thu": 4, "fri": 5, "sat": 6}

def values(field, lo, hi, names=None):
    out = set()
    for tok in field.split(","):
        step, base = 1, tok
        if "/" in tok:
            base, step_s = tok.split("/", 1)
            step = int(step_s)
        if base == "*":
            start, end = lo, hi
        elif "-" in base:
            a, b = base.split("-", 1)
            start, end = one(a, names), one(b, names)
        else:
            start = end = one(base, names)
        v = start
        while v <= end:
            if lo <= v <= hi:
                out.add(v)
            v += step
    return out

def one(token, names):
    return int(token) if token.isdigit() else names[token.lower()[:3]]

def fires(expr, when):
    minute, hour, dom, month, dow = expr.split()
    dt = datetime.datetime.fromisoformat(when)
    cron_dow = (dt.weekday() + 1) % 7
    dow_set = values(dow, 0, 7, DOW)
    if 7 in dow_set:
        dow_set.add(0)
    dom_ok = dt.day in values(dom, 1, 31)
    dow_ok = cron_dow in dow_set
    if dom.startswith("*") or dow.startswith("*"):
        day_ok = dom_ok and dow_ok
    else:
        day_ok = dom_ok or dow_ok
    return (
        dt.minute in values(minute, 0, 59)
        and dt.hour in values(hour, 0, 23)
        and dt.month in values(month, 1, 12)
        and day_ok
    )

Backup checklist:

Line Clock time Weekday fires()
15 9 * * 1-5 2026-11-23 09:15 Monday yes
15 9 * * 1-5 2026-11-27 09:15 Friday yes
15 9 * * 1-5 2026-11-28 09:15 Saturday no
15 9 * * 1-5 2026-11-23 09:16 Monday no
15 9 * * 1-5 2026-11-23 15:09 Monday no

15 9 * * mon-fri matched the same yes/no on those dates.

When both day fields are filled in

“09:00 on the 1st, and only if that day is Monday” often comes back as 0 9 1 * 1. On Debian that runs when either field matches:

Line Clock What the date is fires()
0 9 1 * 1 2026-11-01 09:00 Sunday, the 1st yes
0 9 1 * 1 2026-11-02 09:00 Monday, the 2nd yes
0 9 1 * 1 2026-11-03 09:00 Tuesday, the 3rd no

Sunday the 1st still fires — so the “only if Monday” claim fails.

Debian’s way to require both: leave one day field as * and test inside the command (e.g. test $(date +\%u) -eq 1). Keep the backslash before %.

Page line 0 */4 1 * mon: 1st at 00:00 runs; Monday at 00:00 runs; Monday 01:00 skips; Tuesday skips.

1 December 2026 at 00:00 also fires (day-of-month matches) even though it is a Tuesday.

Ask the chat, then check four clocks

Debian cron, five fields, user crontab (not /etc/crontab, and not a six-field scheduler).
Weekdays at 09:15. Day of week 1-5 is Monday through Friday. 0 and 7 are Sunday.
Before you answer, say what these clocks do, and do not change them:
2026-11-23 09:15 Monday, should fire
2026-11-27 09:15 Friday, should fire
2026-11-28 09:15 Saturday, should not
2026-11-23 09:16 Monday, should not
Then give one line. If both the day of month and the day of week are restricted, say that this cron runs when either matches.

Keep the reply when the line is five fields and all four clocks match.

Weekdays 09:15 → check minute/hour/month/day → match → keep. One miss → discard.

09:16 or 15:09 alone is enough to discard a bad line.

Watch-outs

  • Six time fields = different product. Name that scheduler and write a new checklist from its manual.
  • /etc/crontab inserts a username (17 * * * * root). User crontabs do not.
  • @weekly is Sunday midnight (0 0 * * 0) on this page.
  • */2 with Sunday requires both the step and Sunday on Debian’s “starts with *” reading.
  • TZ= does not move the five fields — it affects commands.
  • Keep production crontabs out of the chat. Mark clocks on your machine.

Share

X Facebook LinkedIn
Educational content only. Rankings reflect stated criteria at the update date—not investment advice or permanent performance guarantees.