Basics
Cron Special Characters
Cron special characters make schedules compact. They are powerful, but the meaning changes slightly between Linux cron and Quartz cron.
Linux cron characters
- * means every allowed value.
- , creates a list of values, such as 1,2,3.
- - creates a range, such as 9-17.
- / creates a step, such as */15 or 9-17/2.
- Some cron implementations support names like MON, TUE, JAN, and FEB, but numeric values are the safest portable option.
*/15 9-17 * * 1-5
# every 15 minutes from 9 AM to 5 PM, Monday through FridayQuartz-only characters
Quartz cron supports extra characters that are not standard Linux cron syntax. Treat them as platform-specific.
- ? means no specific value in day-of-month or day-of-week.
- L means last day or last weekday in supported fields.
- W means nearest weekday.
- # means nth weekday of the month, such as 2#1 for the first Monday.
Common mistakes
- Using ? in Linux cron.
- Assuming every platform supports month or weekday names.
- Writing a step value of 0, which is invalid.
FAQ
Does Linux cron support ?
No. The ? character is commonly used in Quartz cron, not standard Linux cron.
Should I use MON or 1 for Monday?
Use numeric values when portability matters. Some platforms accept names, but numbers are safer.