Why a cron job with both day-of-month and day-of-week runs on unexpected days
Setting both day-of-month and day-of-week in a 5-field crontab matches either day rule rather than requiring both on the same date.
Short answer
Under IEEE Std 1003.1 POSIX rules, setting both field 3 (day-of-month) and field 5 (day-of-week) matches their union (OR), not their intersection (AND). A schedule like 0 9 13 * 5 runs on the 13th of every month plus every Friday — 64 times in 2027. Leave field 5 as * and add a date +\%u test to your command, then check next runs in the Cron Expression Explainer.
Open the Cron Expression Explainer
What IEEE Std 1003.1-2024 specifies
Four cron fields combine with AND: minute, hour and month must all match. The POSIX crontab standard (IEEE Std 1003.1-2024, checked 28 November 2026) treats the two day fields differently.
- Only day-of-month set (
0 9 13 * *): field 5 is an asterisk, so it runs only on the 13th (12 runs yearly). - Only day-of-week set (
0 9 * * 5): field 3 is an asterisk, so it runs only on Fridays (52 or 53 runs yearly). - Both day fields restricted (
0 9 13 * 5): neither field is*, so cron matches any day satisfying day-of-month OR day-of-week.
Many cron helpers describe 0 9 13 * 5 in English as “on day 13 and on Friday”. In everyday English, “and” sounds like both conditions at once, yet cron reads it as two separate lists of dates.
Worked example: 0 9 13 * 5 across the 2026 and 2027 calendars
Open 0 9 13 * 5 from 1 January 2027 in the Cron Expression Explainer to inspect each run and matching rule.
In January 2027, the 13th falls on a Wednesday, so January has zero Friday-the-13ths. Under POSIX OR, 0 9 13 * 5 still fires six times in January 2027. Those dates are Fri 1 Jan, Fri 8 Jan, Wed 13 Jan, Fri 15 Jan, Fri 22 Jan and Fri 29 Jan.
| Calendar year | Days numbered 13 | Fridays | Friday-the-13th dates (AND) | Actual 0 9 13 * 5 runs (OR) |
|---|---|---|---|---|
| 2026 | 12 | 52 | 3 (13 Feb, 13 Mar, 13 Nov) | 61 (12 + 52 − 3) |
| 2027 | 12 | 53 | 1 (13 Aug) | 64 (12 + 53 − 1) |
| 2028 (leap year) | 12 | 52 | 1 (13 Oct) | 63 (12 + 52 − 1) |
The same trap hits “first Monday of the month” schedules. Expression 0 9 1-7 * 1 runs on days 1–7 PLUS every Monday all month (10 or 11 runs monthly).
The Vixie cron */N leading-asterisk quirk
Older Debian and Ubuntu Vixie cron builds add another twist on leading-asterisk steps like 0 9 */2 * 1. Open 0 9 */2 * 1 from 1 January 2027 in the Cron Expression Explainer to inspect both interpretations.
- POSIX, Red Hat/Fedora cronie and GitHub Actions (OR): neither
*/2nor1is a bare asterisk. Field 3 steps odd days (1, 3, …, 31), plus every Monday matches too — including even Monday 4 January 2027. - Debian/Ubuntu Vixie cron 3.0pl1 (AND): Vixie’s parser checks only whether the first character of the field is an asterisk. Leading
*/2triggers AND mode, skipping 1, 3 and 4 January and running first on odd Monday 11 January 2027. - Rewriting as
0 9 1-31/2 * 1: both step expressions select the identical odd dates 1 through 31. Starting with 1 instead of an asterisk clears Vixie’s star flag and flips Debian cron back to OR.
Never rely on the leading-asterisk bug for intersection logic. Moving the same crontab from Ubuntu to AlmaLinux, Fedora or GitHub Actions silently multiplies its run count.
Portable fix: keep * in one day field and guard with date
To require BOTH a date and a weekday everywhere, leave one day field as * and check the other in shell.
0 9 13 * * [ "$(date +\%u)" -eq 5 ] && /path/to/job0 9 * * 1 [ "$(date +\%d)" -le 07 ] && /path/to/job- Leave one day field as
*. Putting*in field 3 (0 9 * * 1) wakes cron only four or five Mondays a month instead of seven mornings. - Use ISO weekday
%u(1 = Monday, 5 = Friday, 7 = Sunday). POSIXdate +%uavoids locale names and 0-versus-7 Sunday differences. - Always escape percent signs as
\%inside crontab. POSIX and Linux crontab(5) turn unescaped percent signs into newlines and send trailing text to standard input. Writingdate +%uwithout the backslash cuts the command in half before the closing quote. - Put the date check inside a script if you prefer clean crontabs. Inside a normal shell script file (outside the crontab file itself), write plain
date +%uwithout the backslash.
Coordinating scheduled jobs with teammates across regions? Check local working hours side by side in the Time Zone Meeting Planner before locking in a UTC run window.
When a 5-field crontab is the wrong tool
Standard 5-field cron has no built-in modifier for “last Friday of the month” or “nearest business day to the 15th”. AWS EventBridge uses 6 fields and requires ? on one day field, preventing combined day rules. Systemd timers (OnCalendar=Fri *-*-13 09:00:00) intersect weekday and date with AND natively.
Sources
- The Open Group Base Specifications Issue 8 (IEEE Std 1003.1-2024): crontab (checked 28 November 2026), for day-of-month/day-of-week OR matching and percent-sign newline translation.
- Linux man-pages: crontab(5) (checked 28 November 2026), for cronie day-field behavior and daylight saving skip/repeat notes.
- Debian Manpages: crontab(5) LIMITATIONS (checked 28 November 2026), for Vixie cron’s leading-asterisk check on
*/2day fields. - freedesktop.org: systemd.timer(5) (checked 28 November 2026), for OnCalendar= calendar scheduling.
Spotted a mistake in this guide? Email contact@fasttool.app. We reply within 7 business days.