Please wait...

小波Note

四川 · 成都市8 ℃
English

Second

Minute

Hour

Day

Month

Week

* * * * * *

Correct

Cron expressions are used to define scheduled tasks in Unix/Linux systems. A cron expression consists of five or six fields, each representing a different time unit.

README.md
        * * * * * *
- - - - - -
| | | | | |
| | | | | +---- Day of the week (0 - 7) (0 or 7 represents Sunday)
| | | | +------ Month (1 - 12)
| | | +-------- Day of the month (1 - 31)
| | +---------- Hour (0 - 23)
| +------------ Minute (0 - 59)
+-------------- Second (0 - 59)

    

Field Descriptions

  1. Second (0 - 59): Specifies the second at which the task will be executed every minute.
  2. Minute (0 - 59): Specifies the minute at which the task will be executed every hour.
  3. Hour (0 - 23): Specifies the hour at which the task will be executed every day.
  4. Day of the month (1 - 31): Specifies the day of the month on which the task will be executed.
  5. Month (1 - 12): Specifies the month of the year in which the task will be executed.
  6. Day of the week (0 - 7): Specifies the day of the week on which the task will be executed (0 or 7 represents Sunday).

Special Characters

  1. *: Represents all possible values. For example, * in the minute field means every minute.
  2. ,: Represents a list of values. For example, 1,2,3 in the hour field means at 1 AM, 2 AM, and 3 AM.
  3. -: Represents a range of values. For example, 1-5 in the day of the month field means from the 1st to the 5th.
  4. /: Represents step values. For example, */5 in the minute field means every 5 minutes.
  5. ?: Can only be used in the day of the month and day of the week fields, and it means no specific value.
  6. L: Can only be used in the day of the month and day of the week fields, and it means the last day. For example, 5L in the day of the month field means the last day of the month.
  7. W: Can only be used in the day of the month field, and it means the nearest weekday. For example, 5W in the day of the month field means the nearest weekday to the 5th.
  8. #: Can only be used in the day of the week field, and it means the nth occurrence of a specific day of the week. For example, 6#3 in the day of the week field means the third Friday of the month.
  9. Day of the week: Use abbreviations (SUN, MON, TUE, WED, THU, FRI, SAT) in the day of the week field to specify the day.
  10. Month: Use abbreviations (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC) in the month field to specify the month.

Special Strings

  1. @reboot: Execute at system startup.
  2. @yearly or @annually: Execute once a year, equivalent to 0 0 1 1 *.
  3. @monthly: Execute once a month, equivalent to 0 0 1 * *.
  4. @weekly: Execute once a week, equivalent to 0 0 * * 0.
  5. @daily or @midnight: Execute once a day, equivalent to 0 0 * * *.
  6. @hourly: Execute once an hour, equivalent to 0 * * * *.
Astral