# Schedule Cron Jobs for Market Hours (09:30–16:00 Mon–Fri in America/New_York)

> Why a single cron expression cannot start at 09:30 and end at 16:00 without skipping :00–:29 in later hours, and how to split half-hour trading windows cleanly.

- **Canonical URL**: https://opslint.dev/cron/business-hours-market-open-half-hour-cron/
- **Category**: `CRON`
- **Interactive Workbench**: [Open in Live Workbench](https://opslint.dev/cron/#expr=30-59%2F5%209%20*%20*%201-5&tz=America%2FNew_York)
- **Normative Specifications**: `POSIX.1-2017 crontab Independent Field Cartesian Product`, `IANA tzdb America/New_York (NYSE / NASDAQ Regular Trading Hours)`

## Incident Symptom & Root Cause

**Production Symptom**: Trying to run an intraday equity feed or SLA check every 5 minutes during NYSE market hours (09:30 to 16:00 ET, Monday–Friday) using 30-59/5 9-16 * * 1-5 skips the first 30 minutes of EVERY hour from 10:00 through 16:25!

**Protocol / Engine Root Cause**: A single cron expression computes the Cartesian product of its Minute set and its Hour set: restricting minutes to 30-59 applies to ALL hours in 9-16, not just hour 9! Any window starting or ending on a half-hour (or quarter-hour) requires splitting the opening partial hour, full middle hours, and closing tick into separate schedule entries.

## Remediation Diff (Broken vs Verified Fix)

### Broken Cartesian-Product Market Window Cron

```text
# BROKEN: Only runs at :30..:55 of EVERY hour (misses 10:00-10:25, 11:00-11:25...
# and keeps firing until 16:55 after the 16:00 closing bell!)
30-59/5 9-16 * * 1-5 /opt/trading/poll-quotes.sh
```

### Exact 3-Rule NYSE Regular Market Hours Split (09:30–16:00 ET)

```text
# GitHub Actions / Multi-rule Cron in America/New_York:
# Rule 1: Opening half-hour (09:30, 09:35, 09:40, 09:45, 09:50, 09:55)
30-59/5 9 * * 1-5 /opt/trading/poll-quotes.sh

# Rule 2: Full trading hours 10:00 through 15:55 (every 5 minutes)
*/5 10-15 * * 1-5 /opt/trading/poll-quotes.sh

# Rule 3: Exact 16:00 closing bell snapshot
0 16 * * 1-5 /opt/trading/poll-quotes.sh
```

## Engineering Deep Dive

Every cron rule evaluates field predicates independently: matches(t) = inMinutes(t.min) AND inHours(t.hour) AND inMonth(t.mon) AND inDay(t). Because there is no conditional coupling between minute and hour inside a single line, rectangular subsets of the (hour, minute) grid fit in one expression (such as 09:00–16:59), whereas ragged start/end boundaries like 09:30–16:00 must be partitioned into disjoint rectangles.

Partitioning 09:30–16:00 into three non-overlapping lines (30-59/5 9, */5 10-15, and 0 16) guarantees zero duplicate triggers at hour boundaries and zero blind spots between 10:00 and 10:29. Always anchor all three rules to timezone: America/New_York (not a fixed UTC offset!) because US Daylight Saving Time shifts relative to UTC on different Sundays than London or Frankfurt—hardcoding 14:30 UTC breaks US market open for three weeks every spring/autumn relative to European servers and for the entire summer unless manually edited!

If your platform enforces a single cron string per job resource (for example a single Kubernetes CronJob object where splitting into three CronJobs would defeat concurrencyPolicy: Forbid), run a single superset schedule */5 9-16 * * 1-5 in America/New_York and start the script with an immediate wall-clock time-of-day guard: hm=$(TZ=America/New_York date +%H%M); [ "$hm" -ge 0930 ] && [ "$hm" -le 1600 ] || exit 0.

## Half-Hour Business Window Decomposition Patterns

| Case / Engine | Protocol Behavior | Production Remediation |
| :--- | :--- | :--- |
| **09:30–09:59 opening window** (`#nyse-open-half-hour`) | Minutes restricted to 30-59 for hour 9 only. | 30-59/5 9 * * 1-5 (fires 09:30, 09:35 .. 09:55). |
| **10:00–15:59 core trading hours** (`#nyse-core-hours`) | All 60 minutes active across hours 10, 11, 12, 13, 14, 15. | */5 10-15 * * 1-5 (fires 10:00 .. 15:55). |
| **16:00 exact market close** (`#nyse-closing-bell`) | Single closing tick without running 16:05–16:55. | 0 16 * * 1-5 (fires once at 16:00:00). |
| **Single K8s CronJob preserving Forbid lock** (`#single-k8s-cronjob-superset`) | Multiple K8s CronJobs cannot share concurrencyPolicy: Forbid. | Use */5 9-16 * * 1-5 with timeZone: America/New_York + [ "$(date +%H%M)" -ge 0930 ] guard. |

## Frequently Asked Engineering Questions

### What about NYSE early-close days (13:00 ET on July 3, Black Friday, Christmas Eve)?

Cron expressions have no market holiday or early-close calendar. Query an exchange calendar library (such as exchange_calendars or Polygon/IEX market status API) at startup and exit 0 cleanly when the market is closed.

### Does [ "$(date +%H%M)" -ge 0930 ] trigger an octal error in /bin/sh because of leading 0 in 0930?

Great catch! POSIX test [ '0930' -ge '0930' ] parses base-10 decimal strings safely in dash, bash, and BusyBox test ([ ... ]), UNLIKE arithmetic expansion $(( 0930 )) which treats leading zero as octal! To be 100% immune in every shell context, compare fixed-width 4-digit HHMM strings lexicographically in awk or strip leading zero.

### How do I write 09:30–16:00 in AWS EventBridge Scheduler?

Create three aws_scheduler_schedule resources with schedule_expression_timezone = 'America/New_York': cron(30/5 9 ? * MON-FRI *), cron(0/5 10-15 ? * MON-FRI *), and cron(0 16 ? * MON-FRI *).

## Related Problem-Cluster Guides

- [Run a Cron Job Every 90 Minutes or Every 45 Minutes (Cross-Hour Split Pattern)](https://opslint.dev/cron/every-90-minutes-cross-hour-cron-split/) — Why */90 and */45 fail to produce uniform cross-hour intervals in cron, and how to split 45-minute and 90-minute schedules into exact dual cron expressions.
- [AWS EventBridge Rules (UTC Only) vs EventBridge Scheduler (IANA Timezones)](https://opslint.dev/cron/aws-eventbridge-rules-utc-vs-scheduler-timezone/) — Why legacy CloudWatch / EventBridge Rules ignore local timezones and DST, and how to migrate to AWS EventBridge Scheduler with ScheduleExpressionTimezone.
- [Kubernetes CronJob .spec.timeZone, CRON_TZ Rejection, and ConcurrencyPolicy Guide](https://opslint.dev/cron/kubernetes-cronjob-timezone-and-concurrency-policy/) — Configure IANA timezones safely in Kubernetes v1.27+ CronJobs, fix rejected CRON_TZ/TZ prefixes in .spec.schedule, and choose between Forbid and Replace.
- [Cron Jobs Skipped During Daylight Saving Time Spring Forward (02:00–02:59 Gap)](https://opslint.dev/cron/dst-spring-forward-skipped-jobs/) — Why 02:30 local cron schedules vanish on Kubernetes CronJob and AWS EventBridge while Vixie Cron runs catch-up at 03:00, and how to prevent missed runs.
