Cron Fundamentalsintermediate

What is Hash Modifier (#)?

An extended cron character for the Nth occurrence of a weekday in a month.

Definition

The hash (#) modifier specifies the Nth occurrence of a given weekday within a month. Written as "day#occurrence" in the day-of-week field: 5#3 means "the third Friday of the month," 1#1 means "the first Monday," and 2#4 means "the fourth Tuesday." It only works in the day-of-week field and is not supported by standard POSIX cron.

💡

Simple Analogy

Like saying "the second Tuesday of every month" for a recurring meeting — the # picks out exactly which occurrence of that weekday you want.

Why It Matters

Many business events follow "Nth weekday" patterns: board meetings on the first Monday, maintenance windows on the third Saturday, payroll on the second and fourth Friday. Without #, you would need complex logic to calculate these dates.

How to Verify

Verify your cron implementation supports #. Use the Cron Explainer to check next runs. For "second Tuesday" (2#2), verify the dates actually fall on the second Tuesday of each month.

⚠️

Common Mistakes

Using # in the day-of-month field — it only works in day-of-week. Writing 5#6 when a month only has 4 or 5 Fridays — the job simply does not run that month. Confusing the day numbering: 1 = Monday (or Sunday in some implementations), not Monday universally.

Best Practices

Always verify the day numbering convention for your cron implementation. Document the schedule in plain English alongside the expression: "2#2 = second Tuesday." Accept that some months may not have a 5th occurrence — your job will skip those months.

Cron Expression Generator

Build your cron expression

Try it free →

Frequently Asked Questions

What is Hash Modifier (#)?

The hash (#) modifier specifies the Nth occurrence of a given weekday within a month. Written as "day#occurrence" in the day-of-week field: 5#3 means "the third Friday of the month," 1#1 means "the first Monday," and 2#4 means "the fourth Tuesday." It only works in the day-of-week field and is not supported by standard POSIX cron.

Why does Hash Modifier (#) matter for cron jobs?

Many business events follow "Nth weekday" patterns: board meetings on the first Monday, maintenance windows on the third Saturday, payroll on the second and fourth Friday. Without #, you would need complex logic to calculate these dates.

What are best practices for Hash Modifier (#)?

Always verify the day numbering convention for your cron implementation. Document the schedule in plain English alongside the expression: "2#2 = second Tuesday." Accept that some months may not have a 5th occurrence — your job will skip those months.

Related Terms

What is Hash Modifier (#)? | CronJobPro