Cron Expression Format
A Cron expression is a string comprising five or six fields separated by white space that represents a set of times.
| Field | Values | Special Characters |
|---|---|---|
| Minute | 0-59 | , - * / |
| Hour | 0-23 | , - * / |
| Day of Month | 1-31 | , - * / ? L W |
| Month | 1-12 or JAN-DEC | , - * / |
| Day of Week | 0-7 (0 or 7 is Sun) or SUN-SAT | , - * / ? L # |
Common Examples
-
*/5 * * * *Every 5 minutes -
0 2 * * *At 02:00 AM every day -
0 8 * * 1Every Monday at 08:00 AM -
0 0 1,15 * *On the 1st and 15th of every month -
0 9-18 * * 1-5Every hour from 9 AM to 6 PM, Mon-Fri
FAQ
Is standard Crontab 5 fields?
Yes, standard Linux Crontab uses 5 fields (Minute, Hour, Day, Month, Week). Extended versions
like Quartz might support 6 (seconds) or 7 (year). This tool generates the standard 5-field
format.
What does asterisk (*) mean?
The asterisk indicates every possible value for that field (e.g., * in Hour field means "every
hour").
What is the difference between '?' and '*'?
'*' stands for any value. '?' is used in 'Day of Month' and 'Day of Week' fields to denote 'no
specific value'. When you specify a value in one of these fields (e.g., Monday), you should
usually set the other to '?' (in Quartz standard) to avoid conflict.
How to set execution every 30 minutes?
Use the slash '/' for step values. For example, '*/30 * * * *' means every 30 minutes starting
from minute 0 (00:00, 00:30, ...).
How to execute only on weekdays?
Use '1-5' (Mon-Fri) in the 'Day of Week' field. Example: '0 9 * * 1-5' runs at 9 AM on weekdays.
Why is my Cron job not running?
Common reasons include: 1. Script permission issues (chmod +x); 2. Environment variable issues
(Cron has a limited PATH, use absolute paths); 3. Server timezone differences.
Can I schedule by seconds?
Standard Linux Crontab has 1-minute granularity. For seconds, use 'sleep' (e.g., 'sleep 30;
command') or a scheduler like Quartz.
What mean L, W, #?
These are extended characters for advanced schedulers (like Quartz). 'L' means Last, 'W' means
Weekday, '#' specifies the nth weekday of the month. Standard Linux Cron does not support these.