You just Googled "cron every 2 weeks" because your clean-up job keeps running weekly, and the cron docs are silent on the whole idea. That's not your fault — the 5-field format has no concept of week parity. There's no */2w, no every-other. But there's a day-of-month trick that gives you a real biweekly cadence, and it's not what most people write.
The trap most people fall into.
Writing 0 0 * * 1 (every Monday) and hoping it means "every other Monday." It doesn't. That expression fires every single Monday. Every week. The exact thing you were trying to avoid.
The expression that works.
You need a day-of-month window that exists in only one of the two weeks. The classic:
0 0 1-7,15-21 * 1
Every 2 weeks on Monday at midnight. Monday lands on day-of-month 1–7 in one week of the month and 15–21 in the next — so it fires exactly once per fortnight. Every month, no matter how long it is, because windows 1–7 and 15–21 always exist.
The same trick, other weekdays.
0 0 1-7,15-21 * 5 # every 2 weeks on Friday (payroll, reports)
0 9 8-14,22-28 * 3 # every 2 weeks on Wednesday at 9 AM
30 4 1-7,15-21 * 0 # every 2 weeks on Sunday at 4:30 AM
The pitfalls that break it.
- Avoid windows that end near day 28 (like
22-28) — they vanish in short months. - Prefer windows that never cross into the next month.
- If you want every 2 weeks on a specific date like the 1st, you can't express that in cron alone — no day-of-month value is "every other month."
The cleaner alternative.
Honestly? For anything more complex than this, don't fight the format. Keep a plain weekly line (0 0 * * 1) as the trigger and let a tiny wrapper script track a timestamp and skip every other run. It's boring, it's readable, and it doesn't break in February. Application schedulers like APScheduler or croniter handle biweekly with plain calendar arithmetic — no day-of-month acrobatics.
I keep a full reference of verified biweekly expressions plus this exact guide at https://cron-generator-kappa.vercel.app/guides/cron-every-two-weeks — bookmark it and you'll never reconstruct the windows from memory again. And if your cron never seems to fire at all, that's a different bug — but that one's usually a timezone, not the schedule.
Cron's 5 fields can't do "every 2 weeks" natively. The day-of-month window is the workaround, and now you've got the expressions to copy.
Which biweekly jobs do you run? Every-other-Monday reports, or something else? I'd genuinely like to hear what people are scheduling — the answers usually reveal a cleaner pattern than my day-of-month trick.
Top comments (0)