Crontab
Utseende
Crontab Time Syntax
[redigera | redigera wikitext]The crontab time format consists of 5 fields that represent different time intervals, followed by the command to be executed. Here's how it works:
Crontab Time Format
[redigera | redigera wikitext]| Minute | Hour | Day of the Month | Month | Day of the Week |
|---|---|---|---|---|
| 0-59 | 0-23 | 1-31 | 1-12 | 0-7 |
- **Minute (0 - 59):** Specifies the minute of the hour when the command should run.
- **Hour (0 - 23):** Specifies the hour of the day (24-hour format) when the command should run.
- **Day of the Month (1 - 31):** Specifies the day of the month when the command should run.
- **Month (1 - 12):** Specifies the month of the year when the command should run.
- **Day of the Week (0 - 7):** Specifies the day of the week when the command should run. Both 0 and 7 represent Sunday.
Special Characters
[redigera | redigera wikitext]Crontab uses several special characters to allow flexible scheduling:
- `*` (Asterisk): Represents every value for that field. For example, `*` in the minute field means the command runs every minute.
- `,` (Comma): Used to specify multiple values. For example, `1,5,10` in the day of the month field means the command runs on the 1st, 5th, and 10th of the month.
- `-` (Dash): Used to specify a range of values. For example, `1-5` in the day of the week field means the command will run Monday through Friday.
- `/` (Slash): Used to specify step values. For example, `*/5` in the minute field means the command runs every 5 minutes.
Crontab Examples
[redigera | redigera wikitext]Below are some examples of crontab entries:
- Run at 7:00 AM every day:
0 7 * * * <command>