Cron first working day of the month

A standard cron expression cannot run a job on the first working day of the month. Cron has no field for "the first weekday, or the next later day if that weekday is a holiday". The reliable fix on your own machine is to run a daily cron job and let a short script decide whether today is the first working day.

Why a plain cron expression is not enoughLink to this section

The expression people often try first is 0 9 1 * 1-5. The intent is "09:00 on the 1st, but only Monday to Friday". In Vixie cron and cronie, that is not what it means. When both the day-of-month and the day-of-week fields are restricted (not *), the fields are combined with OR. The job then runs on the 1st, whatever weekday it is, and also at 09:00 on every Monday to Friday of the month.

A first-weekday rule also has to move off a weekend start: if the 1st is a Saturday, the first weekday is Monday the 3rd; if the 1st is a Sunday, it is Monday the 2nd. Quartz and Spring support 1W, the weekday nearest the 1st in the same month, which covers that weekend case. It still has no holiday calendar. On Friday 1 January 2027, New Year's Day in the United States, a first-weekday or 1W rule fires. The first US business day that month is Monday 4 January.

"Working day" and "business day" are not always the same. If you only skip Saturday and Sunday, use the script below without a holiday file. If you also skip public holidays, add the holiday file.

A daily cron plus a checkLink to this section

Run the check every day, then start the real job only when the script exits 0.

cron
HOLIDAYS_FILE=/etc/us-holidays.txt
0 9 * * * /usr/local/bin/first-business-day.sh && /usr/local/bin/month-start-job

The shell script below uses GNU date (Linux). Pass a date as YYYY-MM-DD to test a day other than today. Without HOLIDAYS_FILE, Saturday and Sunday are the only non-working days. With a file of YYYY-MM-DD holidays, one date per line, the script walks forward from the 1st until it finds a weekday that is not in the list.

bash
#!/usr/bin/env bash
# Exit 0 only if the given date (default: today) is the first business day of its month.
# Weekends are Saturday and Sunday. Optional HOLIDAYS_FILE has one YYYY-MM-DD per line.
set -euo pipefail

day="${1:-$(date +%F)}"

is_weekend() {
  local dow
  dow=$(date -d "$1" +%u) # 1=Monday ... 7=Sunday
  [[ "$dow" -ge 6 ]]
}

is_off() {
  if is_weekend "$1"; then
    return 0
  fi
  if [[ -n "${HOLIDAYS_FILE:-}" && -f "${HOLIDAYS_FILE}" ]]; then
    if grep -qx "$1" "$HOLIDAYS_FILE"; then
      return 0
    fi
  fi
  return 1
}

year=$(date -d "$day" +%Y)
month=$(date -d "$day" +%m)
candidate=$(date -d "$year-$month-01" +%F)
while is_off "$candidate"; do
  candidate=$(date -d "$candidate +1 day" +%F)
done

if [[ "$candidate" == "$day" ]]; then
  exit 0
fi
exit 1

This script was tested on every date in 2026 and 2027 against the United States federal holiday calendar from python-holidays 0.109. A Node.js port of the same rules was tested on the same 730 days and agreed in every case. You still have to keep the holiday file up to date, and the cron entry still starts once every day.

First weekday and first US business day, 2026-2027Link to this section

The table uses a Saturday-Sunday weekend and the United States federal calendar, including observed dates. That is the calendar produced by python-holidays for country code US, which is the library AnyMoment's business calendar uses. "First weekday" ignores holidays. "First US business day" skips them. Rows that differ are marked with an asterisk.

MonthFirst calendar dayFirst weekdayFirst US business day
Jan 2026Thu 2026-01-01Thu 2026-01-01Fri 2026-01-02 *
Feb 2026Sun 2026-02-01Mon 2026-02-02Mon 2026-02-02
Mar 2026Sun 2026-03-01Mon 2026-03-02Mon 2026-03-02
Apr 2026Wed 2026-04-01Wed 2026-04-01Wed 2026-04-01
May 2026Fri 2026-05-01Fri 2026-05-01Fri 2026-05-01
Jun 2026Mon 2026-06-01Mon 2026-06-01Mon 2026-06-01
Jul 2026Wed 2026-07-01Wed 2026-07-01Wed 2026-07-01
Aug 2026Sat 2026-08-01Mon 2026-08-03Mon 2026-08-03
Sep 2026Tue 2026-09-01Tue 2026-09-01Tue 2026-09-01
Oct 2026Thu 2026-10-01Thu 2026-10-01Thu 2026-10-01
Nov 2026Sun 2026-11-01Mon 2026-11-02Mon 2026-11-02
Dec 2026Tue 2026-12-01Tue 2026-12-01Tue 2026-12-01
Jan 2027Fri 2027-01-01Fri 2027-01-01Mon 2027-01-04 *
Feb 2027Mon 2027-02-01Mon 2027-02-01Mon 2027-02-01
Mar 2027Mon 2027-03-01Mon 2027-03-01Mon 2027-03-01
Apr 2027Thu 2027-04-01Thu 2027-04-01Thu 2027-04-01
May 2027Sat 2027-05-01Mon 2027-05-03Mon 2027-05-03
Jun 2027Tue 2027-06-01Tue 2027-06-01Tue 2027-06-01
Jul 2027Thu 2027-07-01Thu 2027-07-01Thu 2027-07-01
Aug 2027Sun 2027-08-01Mon 2027-08-02Mon 2027-08-02
Sep 2027Wed 2027-09-01Wed 2027-09-01Wed 2027-09-01
Oct 2027Fri 2027-10-01Fri 2027-10-01Fri 2027-10-01
Nov 2027Mon 2027-11-01Mon 2027-11-01Mon 2027-11-01
Dec 2027Wed 2027-12-01Wed 2027-12-01Wed 2027-12-01

In January 2026 the first weekday is Thursday 1 January, New Year's Day, so the first US business day is Friday 2 January. In January 2027 the first weekday is Friday 1 January, New Year's Day, so the first US business day is Monday 4 January. Several other months start on a weekend, so even a weekday-only rule must move: February 2026 starts on Sunday the 1st (first weekday Monday 2), and August 2026 starts on Saturday the 1st (first weekday Monday 3). That is why 0 9 1 * * is not a first-working-day schedule.

If your weekend is not Saturday and Sunday, or you close on extra days, change the weekend test and the holiday file. The dates above will no longer apply.

An option that fires only on that dayLink to this section

If you would rather not run a daily filter or maintain a holiday file, AnyMoment can store the rule and POST to your URL only on the first business day.

In the app, describe the rule in plain language, for example: "first business day of every month at 09:00, using the US holiday calendar". Preview the dates before you rely on them. The HTTP API can set the same rule with type set to nth_business_day and n set to 1, plus a business_calendar: a country code such as US or GB, an optional subdivision, custom weekend_days, extra closures, and extra_workdays. You can also roll a fixed day of the month forward, backward, to the nearest business day, or skip it.

Then create an outgoing webhook subscription on the calendar. AnyMoment POSTs to your HTTPS URL when an occurrence is due (occurrence.due). You can shift that delivery with occurrence_offset_seconds. A signing secret is returned once. Deliveries are logged and can be replayed. The URL can be an n8n Webhook node, a Zapier Catch Hook, Make, or your own server. Outgoing webhooks require a Pro plan or an active trial. New accounts get a 30-day trial with the full product.

Start at anymoment.sineways.tech. The API reference is at api.anymoment.sineways.tech/docs.