The cron format consists of five fields that specify the timing for executing a scheduled task. Each field represents a different unit of time, and they are defined as follows:
* * * * * command_to_execute
Here’s what each asterisk represents:
- Minute (0-59)
- Hour (0-23)
- Day of the month (1-31)
- Month (1-12)
- Day of the week (0-7, where both 0 and 7 represent Sunday)
Special Characters
You can also use special characters in the cron format:
*: Represents any value.,: Separates a list of values.-: Represents a range of values./: Specifies step values.
Examples
30 2 * * *: At 2:30 AM, every day.0 9 * * 1-5: At 9:00 AM, Monday through Friday.*/15 * * * *: Every 15 minutes.
Understanding this format is essential for scheduling tasks effectively using cron jobs.
