Launch offer: 50% off Pro on every one-time tool · ends Oct 25
Cosmovex/tools

Cron on the first Monday of the month: why 0 9 1-7 * 1 does not work

First Monday of month with Cron Studio

This opens the Quartz expression 0 0 9 ? * MON#1, which fires at 9:00 on the first Monday of each month. The page also shows why the five-field crontab version most people write runs far more often.

  1. Check the plain-English line and the next five first-Mondays.
  2. In Quartz, Spring or AWS EventBridge copy the expression; the # does the work.
  3. On plain cron use the Monday schedule plus a date test as in the notes below.
  4. Change #1 to #2, #3 or #4 for other weeks.
cron first monday of the month cron nth weekday of month0 9 1-7 * 1cron second tuesday of the monthquartz cron hash
Open Cron Studio Free to start · no account

What to know

The tempting crontab line is 0 9 1-7 * 1: days 1 to 7, and Monday. It does not mean "Monday within days 1 to 7". When both the day-of-month and the day-of-week field are restricted, Vixie cron runs the job when either matches, so this runs on days 1 to 7 of every month and on every Monday.

The reliable plain-cron form is 0 9 * * 1 [ "$(date +\%d)" -le 7 ] && /path/to/job: run every Monday and continue only when the day of the month is 7 or less, which can only be the first Monday. Quartz, Spring and AWS EventBridge avoid the problem with # (MON#1 is the first Monday, FRI#3 the third Friday), and L after a weekday (FRIL) is the last Friday.

Updated · Cosmovex

Questions

What is the cron expression for the first Monday of every month?

Quartz, Spring and AWS EventBridge: 0 0 9 ? * MON#1. Plain unix cron has no equivalent; run on every Monday and add a test that the date is 7 or less.

Why does 0 9 1-7 * 1 run every Monday?

When day-of-month and day-of-week are both set, standard cron ORs them. The job runs on days 1-7 and on all Mondays.

How do I get the last Friday of the month?

In Quartz, Spring and AWS use FRIL (for example 0 0 17 ? * FRIL). On plain cron, run every Friday and test that the date plus 7 days is in the next month.

Does MON#1 work in GitHub Actions or Kubernetes?

No. They use five-field unix cron, which has no # or L. Use the date-test form there.

The free plan covers everything on this page. Cron Studio Pro ($19, paid once) is described on the Cron Studio page.