cron
Cron Every Other Day or Every 2 Weeks: Why */2 and */14 Fail
Cron step values restart every month and every week, so */2 runs on the 31st and the 1st, and */14 runs three times a month. Measured run lists and fixes that hold up.
By Kyle Hurst ·
You want a job to run every other day, so you write 0 0 */2 * *. Then it runs on January 31 and again on February 1. Cron has no memory between months or weeks: a step like */2 means “every second value of this field, counting from the field’s first value”, and the count starts over on the 1st of every month. So */2 in the day-of-month field means “odd-numbered days”, */14 means “the 1st, 15th and 29th”, and no five-field expression means “every 2 weeks”.
The fix that works on any cron is to run the job daily (or weekly) and let the command decide whether today counts:
# every other day, at 09:00 local time
0 9 * * * [ $(( $(date +\%s) / 86400 \% 2 )) -eq 0 ] && /path/to/job
# every other Monday, at 09:00 local time
0 9 * * 1 [ $(( $(date +\%s) / 604800 \% 2 )) -eq 0 ] && /path/to/job
Inside a crontab every % must be written \%, the modulo operator included. Pick a run time that falls on the same UTC date all year (09:00 in New York does). Both points are explained below, after the measured run lists.
What a step value actually means
The crontab(5) man page shipped with macOS (the Vixie cron one) defines steps like this:
Step values can be used in conjunction with ranges. Following a range with ”/
” specifies skips of the number’s value through the range. […] Steps are also permitted after an asterisk, so if you want to say “every two hours”, just use ”*/2”.
The cronie man page (the cron on Fedora, RHEL and many other Linux systems) adds the sentence that explains the whole problem: “Please note that steps are evaluated just within the field they are applied to.” Its own example: */35 in the minute field does not run every 35 minutes, it runs at :00 and :35 every hour.
In cronie’s entry.c, an asterisk becomes the range first-to-last for that field, and the step is a loop over it: for (i = low_; i <= high_; i += step). For day of month that is 1 to 31, so */2 sets days 1, 3, 5 … 31. Cron checks whether today is in that set. It never asks when the job last ran.
Measured: 0 0 */2 * * across month ends
These run lists come from croniter 7.0.0 (Python) and the npm package cron-parser 5.10.6, both in UTC. The two libraries agreed on every row. For the January row we also ran systemd 262’s systemd-analyze calendar on the equivalent *-*-1/2 00:00, and it listed the same dates.
| Month boundary | Next runs | Gap at the boundary |
|---|---|---|
| Jan to Feb 2027 (31 days) | Jan 27, Jan 29, Jan 31, Feb 1, Feb 3, Feb 5 | 1 day |
| Apr to May 2027 (30 days) | Apr 27, Apr 29, May 1, May 3, May 5 | 2 days |
| Feb to Mar 2027 (28 days) | Feb 23, Feb 25, Feb 27, Mar 1, Mar 3 | 2 days |
| Feb to Mar 2028 (29 days, leap) | Feb 25, Feb 27, Feb 29, Mar 1, Mar 3 | 1 day |
Every month with an odd number of days ends on a run day, and the 1st is always a run day, so you get two runs in a row. Over all of 2027, croniter lists 186 runs with six one-day gaps (end of Jan, Mar, May, Jul, Aug and Oct; the Dec 31 to Jan 1 pair falls into 2028). A true every-other-day job would run 182 or 183 times.
Every 3 days: */3 breaks in more months
*/3 expands to 1, 4, 7, … 28, 31. Same tools, same agreement:
| Month boundary | Next runs | Gap at the boundary |
|---|---|---|
| Jan to Feb 2027 | Jan 25, Jan 28, Jan 31, Feb 1, Feb 4 | 1 day |
| Apr to May 2027 | Apr 25, Apr 28, May 1, May 4 | 3 days |
| Feb to Mar 2027 | Feb 22, Feb 25, Feb 28, Mar 1, Mar 4 | 1 day |
In a 30-day month the pattern happens to come out right. Everywhere else it does not: 2027 has seven one-day gaps and 127 runs, where every third day would give about 122.
”Every 2 weeks”: */14 runs three times in most months
0 0 */14 * * is the expression people reach for when they mean fortnightly. It expands to the 1st, 15th and 29th:
| Run (from Jan 1, 2027) | Gap since previous run |
|---|---|
| Fri Jan 1 | |
| Fri Jan 15 | 14 days |
| Fri Jan 29 | 14 days |
| Mon Feb 1 | 3 days |
| Mon Feb 15 | 14 days |
| Mon Mar 1 | 14 days (no Feb 29 in 2027) |
| Mon Mar 15 | 14 days |
| Mon Mar 29 | 14 days |
croniter counts 35 runs in 2027, with ten gaps of two or three days; a real every-two-weeks job runs 26 or 27 times. The weekday drifts too, so “every other Friday” cannot be written with day-of-month steps. (0 0 1,15 * *, twice a month, is fine if that is what you need. It is just not every two weeks.)
Day-of-week steps do not count weeks
The day-of-week field has the same limit, only shorter: its range is one week. 0 0 * * */2 gives Sunday, Tuesday, Thursday and Saturday (0, 2, 4, 6). Croniter and cron-parser both list Sat Jan 2, Sun Jan 3, Tue Jan 5, Thu Jan 7, … for 2027, so Saturday and Sunday run back to back every weekend. Nothing in the field remembers which week it is, so there is no day-of-week step for “every other Monday”.
Implementations also disagree on the shorter forms. We tested them:
| Expression | cronie 1.7.2 crontab | croniter 7.0.0 | cron-parser 5.10.6 |
|---|---|---|---|
*/2 | accepted | Sun, Tue, Thu, Sat | Sun, Tue, Thu, Sat |
0-6/2 | accepted | Sun, Tue, Thu, Sat | Sun, Tue, Thu, Sat |
0/2 | bad day-of-week, refused | Sun, Tue, Thu, Sat | Sun, Tue, Thu, Sat |
1/2 | bad day-of-week, refused | Mon, Wed, Fri | Mon, Wed, Fri, Sun |
cronie’s parser only allows a step after * or after a range, so 1/2 is a syntax error there. cron-parser reads 1/2 as 1 through 7 in steps of 2, and 7 is Sunday. If you need a weekday list, write it out (1,3,5) and every cron agrees.
One more trap if you mix fields: cronie flags a day-of-month or day-of-week field that starts with * as unrestricted (entry.c), and cron.c only uses the OR rule from our cron cheat sheet when neither field is flagged. So */2 in one day field plus a weekday in the other is an AND.
Fix 1: run daily, gate on the epoch day
Unix time divided by 86,400 is a day counter that never resets, so its parity alternates forever. cronie’s own man page suggests the same trick in its NOTES section, for “every 58 minutes”.
0 9 * * * [ $(( $(date +\%s) / 86400 \% 2 )) -eq 0 ] && /path/to/job
To try the test in a terminal first, drop the backslashes. With them, bash and dash both stop with an arithmetic syntax error on \% 2:
[ $(( $(date +%s) / 86400 % 2 )) -eq 0 ] && echo "runs today"
Why \%: in a crontab, a bare % ends the command. Both man pages say it: an unescaped % is “changed into newline characters, and all data after the first % will be sent to the command as standard input.” That includes the % in date +%s and the modulo %. We installed three lines in cronie 1.7.2 inside a Fedora container and ran crond for a minute. The escaped gate printed gate: odd day, job skipped (epoch day 20777 is odd). The same line with bare % signs wrote nothing at all, because the shell received a truncated command.
The time-zone catch: the epoch counts UTC days, and cron runs your job in local time. If the run time is the same UTC date in winter and in summer, parity alternates cleanly. If it is not, it slips by one day at each DST change. We computed this in Python with zoneinfo for a job at 19:30 in America/New_York, which is 23:30 UTC in summer and 00:30 UTC the next day in winter:
| Local date, 19:30 | Zone | Epoch day | Runs (even)? |
|---|---|---|---|
| Fri Oct 30, 2026 | EDT | 20756 | yes |
| Sat Oct 31 | EDT | 20757 | no |
| Sun Nov 1 | EST | 20759 | no |
| Mon Nov 2 | EST | 20760 | yes |
Day 20758 was skipped, so the job waited three days; gated on odd days, it would have run Saturday and Sunday back to back. At 09:00 New York time (13:00 or 14:00 UTC) it alternated cleanly through both DST changes. So pick a run time that stays on one UTC date all year, run the server on UTC, or count local days. With GNU date, $(( $(date -u -d "$(date +\%F)" +\%s) / 86400 )) turns today’s local date into a day number (crontab escaping shown); for Oct 31, Nov 1 and Nov 2 it gives 20757, 20758 and 20759, with no jump. Our post on storing UTC but displaying local time has more on cron and time zones.
Why not day-of-year parity? date +%j resets every January 1st. In a 365-day year the last day is 365 (odd) and the next day is 001 (odd), so a job gated on odd days runs Dec 31, 2027 and Jan 1, 2028 back to back. It also has a shell trap: %j pads to three digits, and shell arithmetic treats a leading zero as octal, where 8 and 9 are not digits. For January 8 (008), dash on Debian failed with arithmetic expression: expecting EOF (or Illegal number: 008 when the value was in a variable), and bash and macOS /bin/sh said value too great for base. If you use it anyway, %-j drops the padding in GNU and macOS date.
To check today’s epoch day by hand, paste the current time into our timestamp converter and divide the seconds by 86,400.
Fix 2: every two weeks, gate a weekly job
For “every other Monday”, schedule every Monday and gate on a week counter. The obvious one is the ISO week number, date +%V, but it has the same reset problem as day of year. Some ISO years have 53 weeks, and 2026 is one of them (so are 2032 and 2037). Python’s ISO calendar for Mondays:
| Monday | %V | Runs (odd)? |
|---|---|---|
| Dec 14, 2026 | 51 | yes |
| Dec 21, 2026 | 52 | no |
| Dec 28, 2026 | 53 | yes |
| Jan 4, 2027 | 01 | yes, again |
| Jan 11, 2027 | 02 | no |
The epoch-week counter, date +%s divided by 604,800, does not reset. Epoch weeks start on Thursday at 00:00 UTC (January 1, 1970 was a Thursday), so a Monday job is nowhere near a week boundary and DST cannot move it across one:
0 9 * * 1 [ $(( $(date +\%s) / 604800 \% 2 )) -eq 0 ] && /path/to/job
Computed for Monday 09:00 New York time, epoch weeks 2970 to 2976 ran on Dec 7, Dec 21, Jan 4 and Jan 18, straight through the year end. Change -eq 0 to -eq 1 to shift by a week.
Fix 3: systemd timers
OnCalendar= does not escape the problem. systemd.time(7) says a value followed by / matches “the value itself and the value plus all multiples of the repetition value”, inside that field. systemd-analyze calendar '*-*-1/2 00:00' (systemd 262) listed Jan 27, Jan 29, Jan 31, Feb 1, Feb 3: the same back-to-back pair as cron. *-*-*/2 is rejected outright (“Failed to parse calendar specification”).
What systemd has that cron lacks is a timer relative to the last run. systemd.timer(5) describes OnUnitActiveSec= as follows: “Defines a timer relative to when the unit the timer unit is activating was last activated.” The same page notes that combining OnBootSec= with OnUnitActiveSec= gives a timer that elapses at regular intervals:
[Timer]
OnBootSec=15min
OnUnitActiveSec=2d
systemd-analyze timespan 2d confirms the unit (172,800,000,000 µs; 14d normalizes to 2w). The trade-off: this runs every 48 hours from the last run, not at a fixed clock time, and the man page says Persistent= (which stores the last trigger time on disk) “only has an effect on timers configured with OnCalendar=”. The page describes no on-disk memory for OnUnitActiveSec=, so do not count on exact 48-hour spacing across a reboot.
Fix 4: let at schedule the next run
If the job itself can queue its successor, there is no calendar math at all. The last line of the script:
echo /path/to/job.sh | at 09:00 + 2 days
The macOS at(1) page documents this form (“at 4pm + 3 days”), and in a Debian container at queued the line above for 09:00 two days out. Anchoring to a clock time stops drift. The catch is that the chain stops if a run dies before it re-queues, and on macOS the same man page notes that atrun “is disabled by default”.
Hosted schedulers have their own extensions
These are not standard cron, and they only work where documented:
- GitLab pipeline schedules accept
0 9 * * sun%2for every other Sunday. The GitLab cron docs say this comes from the fugit parser’s modulo extension. The fugit README defines it ast.wday == 0 && t.rweek % 2 == 0, whererweekis fugit’s own week counter, not the ISO week.sun%2+1gives the other Sundays. - AWS EventBridge Scheduler has rate expressions,
rate(value unit)with unitsminutes,hoursordays, sorate(2 days)andrate(14 days)are real intervals from the schedule’s start date. Its docs note thatdaysmeans 24 hours, even when DST makes a day 23 or 25. Its six-fieldcron()expressions still use/within each field, like1/10in minutes.
Checking an expression with our tools
Our cron parser describes an expression in plain English and lists the next 10 run times in your browser’s time zone. The crontab builder assembles one field by field, with an “Every N” option that writes */N.
Writing this post is how we found a bug in both. Their next-run code stepped from zero (it tested day % 2 === 0), so 0 0 */2 * * listed even days (Jan 26, 28, 30, Feb 2) where cron runs odd ones, */14 listed the 14th and 28th, and 1-5/2 ignored the range. Both tools now step from the start of the field or range, as cronie’s loop does. Across the end of January, 0 0 */2 * * now lists Jan 27, Jan 29, Jan 31, Feb 1, Feb 3, the dates in the table above, with the description “at minute 0, past hour 0, on every 2nd day of the month, starting on the 1st”. */14 lists the 1st, 15th and 29th, and 1-5/2 in the day-of-week field gives Monday, Wednesday and Friday. The tools also follow cronie’s OR/AND rule for the two day fields, and like cronie they reject 1/2-style steps, suggesting a range such as 1-6/2 instead.