Cron Fundamentalsintermediate

What is W Modifier?

An extended cron character that selects the nearest weekday (Mon-Fri) to a given date.

Definition

The W modifier is a non-standard cron extension that finds the nearest weekday (Monday-Friday) to a specified day of the month. For example, 15W means "the nearest weekday to the 15th." If the 15th falls on Saturday, it runs on Friday the 14th; if it falls on Sunday, it runs on Monday the 16th. It never crosses month boundaries.

๐Ÿ’ก

Simple Analogy

Like scheduling a meeting for "around the 15th, but only on a weekday" โ€” it automatically adjusts to avoid weekends.

Why It Matters

Business-critical tasks like payroll, invoicing, and bank transactions must run on business days. The W modifier ensures your job runs on the nearest weekday without manual calendar adjustments each month.

How to Verify

Test with months where the specified date falls on different days. Check January 2027 (if the 1st is a Friday), February (28th falls on what day?). The Cron Explainer shows adjusted dates.

โš ๏ธ

Common Mistakes

Assuming W crosses month boundaries โ€” it does not. If the 1st is a Saturday, 1W runs on Monday the 3rd, not the previous Friday. Combining W with ranges or lists โ€” 1-15W is invalid. Using W in day-of-week field โ€” it only works in day-of-month.

โœ…

Best Practices

Use W for any business-day-only scheduling need. Combine with L as LW for "last business day of the month." Remember that W only adjusts by 1-2 days โ€” if the 15th is Saturday, it picks Friday 14th; if Sunday, it picks Monday 16th.

Cron Expression Generator

Build your cron expression

Try it free โ†’

Frequently Asked Questions

What is W Modifier?

The W modifier is a non-standard cron extension that finds the nearest weekday (Monday-Friday) to a specified day of the month. For example, 15W means "the nearest weekday to the 15th." If the 15th falls on Saturday, it runs on Friday the 14th; if it falls on Sunday, it runs on Monday the 16th. It never crosses month boundaries.

Why does W Modifier matter for cron jobs?

Business-critical tasks like payroll, invoicing, and bank transactions must run on business days. The W modifier ensures your job runs on the nearest weekday without manual calendar adjustments each month.

What are best practices for W Modifier?

Use W for any business-day-only scheduling need. Combine with L as LW for "last business day of the month." Remember that W only adjusts by 1-2 days โ€” if the 15th is Saturday, it picks Friday 14th; if Sunday, it picks Monday 16th.

Related Terms