Build cron schedule expressions visually. Get a plain-English description of when the schedule runs and see the next 5 execution times.
A cron expression is a string representing a schedule, used by the cron daemon in Unix-like operating systems to execute commands or scripts automatically at specified times. It typically consists of five fields separated by spaces: minute (0-59), hour (0-23), day of the month (1-31), month (1-12 or Jan-Dec), and day of the week (0-6 or Sun-Sat). For example, the expression '0 0 * * *' schedules a task to run every day at midnight. System administrators and developers use cron to automate backups, maintenance tasks, fetching data, and sending scheduled emails.
To run a task every 5 minutes, you use the step value syntax (/) in the minute field. The correct cron expression is '*/5 * * * *'. The asterisk (*) means 'every possible value', and the /5 means 'step by 5'. So '*/5' in the minute field means execution at minutes 0, 5, 10, 15, and so on throughout the hour. Similarly, to run exactly every 15 minutes, you would use '*/15 * * * *'. Do not confuse this with '5 * * * *', which means 'run exactly at the 5th minute of every hour'.
In standard Linux/Unix cron, the asterisk (*) is used to specify 'all values' for that field (e.g., * in the hour field means every hour). Standard Linux cron does not support the question mark (?) character. However, in extended cron schedulers like Quartz (used by Java, Spring, and AWS CloudWatch), the '?' character is used to specify 'no specific value' and is required in either the day-of-month or day-of-week field. For instance, in AWS, if you specify 'day of month' as the 1st, you must set 'day of week' to '?', because a conflict would occur if the 1st of the month does not fall on the explicitly chosen day of the week.
To restrict a cron schedule to weekdays only, you use the 'day of week' field, which is the 5th field in the cron expression. You can define a range using a hyphen (-). The expression '0 9 * * 1-5' will run a task at 9:00 AM every Monday through Friday. Ensure that your 'day of week' representation aligns with your system: typically, 0 represents Sunday and 1 represents Monday, making 1-5 the correct range for weekdays. Alternatively, some systems allow 'MON-FRI'.
Cron is a time-based job scheduler used in Unix-like operating systems. A standard cron expression contains exactly five fields separated by spaces representing: minute (0-59), hour (0-23, 24-hour time), day of the month (1-31), month (1-12), and day of the week (0-6 starting with Sunday, though 7 can also be Sunday on some systems).
There are a few key operators used to configure complex schedules. The asterisk (*) means "every possible value" for a field. The comma (,) allows you to specify a list of values such as 1,15,30 for the 1st, 15th, and 30th minute. A hyphen (-) specifies a range, like 1-5 in the day-of-week field for Monday through Friday. A slash (/) defines step increments; for example, */5 in the minute field means the job runs every 5 minutes.
The "cron expression" is the five-part string that defines the schedule, while a "crontab" (cron table) is the file where you pair that expression with a specific script or command to run. For example, a line in a crontab might look like 0 0 * * * /usr/bin/python3 /scripts/backup.py, which runs the backup script exactly at midnight every single day.