Search for does day of week conflict with day of month in crontab and you usually land on a line that “looks AND” but behaves like OR.

On Vixie cron and cronie—the packages behind crontab on most Linux servers—when both day fields are restricted, the command runs when either one matches. The fields do not wait for both.

What the generator is for

The KeptTools cron expression generator builds a five-field string (minute hour day-of-month month day-of-week) plus a plain-English summary in the browser. It does not install the job. Copy the expression, not the sentence. The page itself warns that some hosts treat day-of-month and day-of-week as “either” when both are set—so you still test on the system that will run it.

Restricted vs star

A star is not a restriction. It means “every,” so that field drops out.

  • 0 9 1 * * → 09:00 on the 1st only
  • 0 9 * * 5 → 09:00 every Friday

The either-day rule starts only when both day fields carry a real restriction: a number, list, range, or a step such as 1-31/2. On Vixie cron and cronie, a day field that starts with * (including */2) counts as unrestricted and then combines with the other day field using AND.

Worked example

0 9 1 * 5 

Intended reading for many people: “09:00 only when the 1st is a Friday.”

Actual Vixie/cronie behavior: 09:00 on the 1st of every month, and also 09:00 every Friday.

The classic crontab(5) shape makes the OR obvious:

30 4 1,15 * 5 

That is 04:30 on the 1st, 04:30 on the 15th, and 04:30 every Friday. One line still runs once on a Friday that is also the 1st.

Weekdays at nine avoid the trap because day-of-month is a star:

0 9 * * 1-5 

How to test on the host

Suppose today is Wednesday the 15th and date +%w prints 3:

* * 31 * 3 date >> /tmp/cron-or-test.log 

Day-of-month is wrong; day-of-week is today. A new line within a minute means either-field behavior. Then:

* * 31 * * date >> /tmp/cron-or-test.log 

That line should stay quiet. Remove both tests—a * minute field means every minute.

Requiring both days

One standard five-field line cannot mean “Friday the 1st only” on Vixie cron. Schedule one field; test the other in the command:

0 9 1 * * [ "$(date +\%u)" -eq 5 ] && /usr/local/bin/job 

In crontab write \%. Call the binary by absolute path—cron’s PATH is often short.

Two separate lines (1st, and Friday) cover the same days as 0 9 1 * 5, except a Friday the 1st can fire twice. A single OR line fires once.

Common mistakes

  • Reading 0 9 1 * 5 as AND (“Friday the 1st only”).
  • Forgetting that 0 9 * * 1-5 is safe because day-of-month is *.
  • Pasting the human-readable sentence from a generator into crontab instead of the five fields.
  • Assuming Kubernetes CronJob, GitHub Actions, BusyBox crond, Quartz, or EventBridge share the Vixie either-day rule without checking their docs.
  • Prepending a seconds field and shifting the five-field line.

Build the fields here, then verify on the host: cron expression generator. Full walkthrough: https://kepttools.com/guides/cron-both-day-fields